-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
51 lines (49 loc) · 1.52 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
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const webpack = require("webpack");
const { basename, dirname, resolve } = require("path");
const srcDir = "src";
const admin = resolve(process.cwd(), srcDir, "admin");
const editor = resolve(process.cwd(), srcDir, "editor");
const subscription = resolve(process.cwd(), srcDir, "subscription");
const subscriptionemail = resolve(process.cwd(), srcDir, "subscriptionemail");
module.exports = {
...defaultConfig,
entry: {
admin,
editor,
subscription,
subscriptionemail,
},
output: {
path: resolve(process.cwd(), "build"),
filename: "[name].js",
clean: true,
},
optimization: {
...defaultConfig.optimization,
splitChunks: {
cacheGroups: {
style: {
type: "css/mini-extract",
test: /[\\/]style(\.module)?\.(pc|sc|sa|c)ss$/,
chunks: "all",
enforce: true,
name(_, chunks, cacheGroupKey) {
const chunkName = chunks[0].name;
return `${dirname(chunkName)}/${basename(
chunkName
)}.${cacheGroupKey}`;
},
},
default: false,
},
},
},
plugins: [
...defaultConfig.plugins,
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
}),
],
};