Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
55 lines (52 loc) · 1.48 KB
/
Copy pathwebpack.config.js
File metadata and controls
55 lines (52 loc) · 1.48 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
50
51
52
53
54
55
const defaultConfig = require("@wordpress/scripts/config/webpack.config");
const path = require("path");
const fs = require("fs");
const blocksDir = path.resolve(__dirname, "src/blocks");
const blocks = fs
.readdirSync(blocksDir)
.filter(
(block) =>
fs.existsSync(path.join(blocksDir, block, "index.js")) ||
fs.existsSync(path.join(blocksDir, block, "view.js")),
);
const entry = {};
blocks.forEach((block) => {
const blockPath = path.join(blocksDir, block);
if (fs.existsSync(path.join(blockPath, "index.js"))) {
entry[`blocks/${block}/index`] = path.join(blockPath, "index.js");
}
if (fs.existsSync(path.join(blockPath, "view.js"))) {
entry[`blocks/${block}/view`] = path.join(blockPath, "view.js");
}
});
module.exports = {
...defaultConfig,
cache: {
type: "filesystem",
cacheDirectory: path.resolve(__dirname, ".cache/webpack"),
buildDependencies: {
config: [__filename],
},
},
performance: {
hints: false,
maxAssetSize: 1048576, // 1MB
maxEntrypointSize: 1048576, // 1MB
},
entry,
output: {
path: path.resolve(__dirname, "build"),
filename: "[name].js",
},
resolve: {
alias: {
...defaultConfig.resolve.alias,
"@Components": path.resolve(__dirname, "src/components/"),
"@Config": path.resolve(__dirname, "src/config/"),
"@Utils": path.resolve(__dirname, "src/utils/"),
"@Blocks": path.resolve(__dirname, "src/blocks/"),
"@Store": path.resolve(__dirname, "src/store/"),
"@Constants": path.resolve(__dirname, "src/fbConstants/"),
},
},
};