-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
42 lines (38 loc) · 1.02 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
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const path = require("path");
const isProduction = "production" === process.env.NODE_ENV;
const {entryPoints} = require("./pluginStage.json");
let entry = {};
if( entryPoints.hasOwnProperty("blocks") ){
entryPoints.blocks.forEach(
(entryPoint) => {
entry[`block-${entryPoint}`] = path.resolve(process.cwd(), `blocks/${entryPoint}/index.js`);
}
);
}
if( entryPoints.hasOwnProperty("adminPages") ){
entryPoints.adminPages.forEach(
(entryPoint) => {
entry[`admin-page-${entryPoint}`] = path.resolve(process.cwd(), `admin/${entryPoint}/index.js`);
}
);
}
module.exports = {
mode: isProduction ? "production" : "development",
...defaultConfig,
module: {
...defaultConfig.module,
rules: [
...defaultConfig.module.rules,
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
],
},
entry,
output: {
filename: "[name].js",
path: path.join(__dirname, "./build"),
},
};