-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.babel.js
52 lines (47 loc) · 1.05 KB
/
webpack.config.babel.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
52
import nodeExternals from 'webpack-node-externals'
const bundle = (_, argv) => {
const clientConfig = {
entry: './build/client.js',
output: {
filename: './app.js',
publicPath: 'http://localhost:9000/',
},
devServer: {
port: 9000,
headers: { 'Access-Control-Allow-Origin': '*' },
disableHostCheck: true,
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: /node_modules/,
use: ['babel-loader'],
},
],
},
stats: {
modules: false,
hash: false,
chunks: false,
chunkModules: false,
version: false,
children: false,
},
}
const serverConfig = {
...clientConfig,
entry: './build/server.js',
target: 'node',
externals: [nodeExternals()],
output: {
path: __dirname,
filename: 'server.js',
publicPath: '/',
},
}
if (argv.for === 'client') return clientConfig
if (argv.for === 'server') return serverConfig
return [clientConfig, serverConfig]
}
export default bundle