forked from Submitty/pdf-annotate.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.sandbox.js
51 lines (43 loc) · 1.04 KB
/
webpack.sandbox.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 fs = require('fs');
const path = require('path');
const SANDBOX_DIR = path.resolve(process.cwd(), 'sandbox');
function buildEntries() {
return fs.readdirSync(SANDBOX_DIR).reduce((entries, dir) => {
if (dir === 'build' || dir === 'shared') {
return entries;
}
let isDraft = dir.charAt(0) === '_';
let isDirectory = fs.lstatSync(path.join(SANDBOX_DIR, dir)).isDirectory();
if (!isDraft && isDirectory) {
entries[dir] = path.join(SANDBOX_DIR, dir, 'index.js');
}
return entries;
}, {});
}
module.exports = {
entry: buildEntries(),
mode: 'development',
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.join(__dirname, 'sandbox', '__build__'),
publicPath: '/__build__/'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
},
optimization: {
splitChunks: {
name: 'shared.js'
}
}
};