-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
webpack.config.js
44 lines (42 loc) · 1.2 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
const path = require('node:path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const defaultConfig = require('@wordpress/scripts/config/webpack.config.js');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const config = {
...defaultConfig,
...{
context: path.resolve(process.cwd(), 'assets', 'src'),
entry: {
field: [
path.resolve(process.cwd(), 'assets', 'src', 'js', 'field.js'),
path.resolve(process.cwd(), 'assets', 'src', 'css', 'field.css'),
],
},
output: {
filename: '[name]-[contenthash].js',
path: path.resolve(process.cwd(), 'assets', 'dist'),
clean: true,
}
},
plugins: [
...defaultConfig.plugins.filter(
plugin =>
! [ 'DependencyExtractionWebpackPlugin' ].includes(
plugin.constructor.name
)
).map(plugin => {
if(plugin.constructor.name === 'MiniCssExtractPlugin') {
console.log(plugin.constructor.name);
return new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css',
});
}
return plugin;
}),
new WebpackManifestPlugin({
basePath: '',
publicPath: '',
}),
],
};
module.exports = config;