-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
50 lines (44 loc) · 1.21 KB
/
webpack.config.js
File metadata and controls
50 lines (44 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Webpack Configuration
*
* Customizes @wordpress/scripts webpack config to output separate CSS files.
*
* @package MegaMenuBlock
*/
const RemoveEmptyScriptsPlugin = require( 'webpack-remove-empty-scripts' );
const path = require( 'path' );
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
module.exports = {
...defaultConfig,
entry: {
index: path.resolve( process.cwd(), 'src/js/index.js' ),
editor: path.resolve( process.cwd(), 'src/css/editor.css' ),
style: path.resolve( process.cwd(), 'src/css/style.css' ),
},
module: {
...defaultConfig.module,
rules: [
// Add our raw SVG loader BEFORE the default rules so it takes precedence
// This must come first to override WordPress scripts' default SVG handling
{
test: /\.svg$/,
resourceQuery: /raw/,
use: {
loader: 'raw-loader',
options: {
esModule: false, // Use CommonJS format for better compatibility
},
},
type: 'javascript/auto', // Override any default type
},
...defaultConfig.module.rules,
],
},
plugins: [
...defaultConfig.plugins,
new RemoveEmptyScriptsPlugin( {
enabled: true,
stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS,
} ),
],
};