-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
55 lines (51 loc) · 1.27 KB
/
webpack.config.js
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
50
51
52
53
54
55
const jetpackWebpackConfig = require( '@automattic/jetpack-webpack-config/webpack' );
const { glob } = require( 'glob' );
const sharedWebpackConfig = {
mode: jetpackWebpackConfig.mode,
devtool: jetpackWebpackConfig.devtool,
output: jetpackWebpackConfig.output,
optimization: {
...jetpackWebpackConfig.optimization,
},
resolve: {
...jetpackWebpackConfig.resolve,
modules: [ 'node_modules' ],
alias: {
...jetpackWebpackConfig.resolve.alias,
fs: false,
},
},
node: {},
externals: {
...jetpackWebpackConfig.externals,
jetpackConfig: JSON.stringify( {
consumer_slug: 'jetpack-classic-theme-helper',
} ),
},
module: {
strictExportPresence: true,
rules: [
// Transpile JavaScript
jetpackWebpackConfig.TranspileRule( {
exclude: /node_modules\//,
} ),
// Handle CSS.
jetpackWebpackConfig.CssRule( {
extensions: [ 'css' ],
} ),
],
},
plugins: [ ...jetpackWebpackConfig.StandardPlugins() ],
};
const classicThemeHelperFiles = {};
for ( const file of glob
.sync( 'src/**/*.js' )
.filter( name => ! name.endsWith( '.min.js' ) && name.indexOf( '/test/' ) < 0 ) ) {
classicThemeHelperFiles[ file.substring( 4, file.length - 3 ) ] = './' + file;
}
module.exports = [
{
...sharedWebpackConfig,
entry: classicThemeHelperFiles,
},
];