-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathwebpack.config.js
More file actions
39 lines (35 loc) · 927 Bytes
/
webpack.config.js
File metadata and controls
39 lines (35 loc) · 927 Bytes
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
const defaultConfig = require('@wordpress/scripts/config/webpack.config');
const path = require('path');
const glob = require('glob');
// Find all block.json files
const blockEntries = glob.sync('./src/blocks/*/block.json').map(file => {
const blockDir = path.dirname(file);
const blockName = path.basename(path.dirname(file));
return {
name: blockName,
path: path.resolve(blockDir, 'index.ts'),
};
});
// Create entry points for each block
const entries = {
index: path.resolve(process.cwd(), 'src', 'index.ts'),
};
// Add block entries
blockEntries.forEach(block => {
entries[block.name] = block.path;
});
module.exports = {
...defaultConfig,
entry: entries,
output: {
...defaultConfig.output,
path: path.resolve(process.cwd(), 'build'),
},
resolve: {
...defaultConfig.resolve,
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
alias: {
'@': path.resolve(process.cwd(), 'src'),
},
},
};