forked from algorithm-visualizer/algorithm-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.backend.config.js
45 lines (42 loc) · 961 Bytes
/
webpack.backend.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
const CleanWebpackPlugin = require('clean-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const fs = require('fs');
const {
__DEV__,
backendBuildPath: buildPath,
backendSrcPath: srcPath,
} = require('./environment');
const alias = {
'/environment': path.resolve(__dirname, 'environment.js'),
};
fs.readdirSync(srcPath).forEach(name => {
alias['/' + name] = path.resolve(srcPath, name);
});
module.exports = {
target: 'node',
node: {
__dirname: true,
},
entry: srcPath,
externals: [nodeExternals()],
resolve: {
modules: [srcPath],
extensions: ['.js'],
alias,
},
output: {
path: buildPath,
filename: 'index.js',
libraryTarget: 'umd',
},
module: {
rules: [
{ test: /\.js$/, use: 'babel-loader', include: srcPath },
],
},
plugins: [
new CleanWebpackPlugin([buildPath]),
],
mode: __DEV__ ? 'development' : 'production',
};