-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (86 loc) · 2.14 KB
/
webpack.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const path = require('path');
const ESLintLoader = require('eslint-webpack-plugin');
const NodemonPlugin = require('nodemon-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const pure_funcs = [];
if (process.env.ENV === 'prod') {
pure_funcs.push('console.log');
}
module.exports = {
entry: ['./'],
target: 'node',
output: {
filename: 'server.js',
path: path.resolve(__dirname, 'bin'),
publicPath: '/bin/'
},
externals: [{ express: "require('express')" }],
devtool: 'inline-source-map',
devServer: {
port: 3888, // default: 8080
open: true, // open page in browser
static: {
directory: path.join(__dirname, 'public')
}
},
module: {
rules: [
{
test: /\.(m|c)?(js)$/,
exclude: /node_modules/,
use: ['babel-loader']
}
]
},
optimization: {
minimize: process.env.ENV !== 'local',
minimizer: [
new TerserPlugin({
test: /\.(m|c)?(js)$/,
extractComments: true,
parallel: true,
terserOptions: {
compress: {
pure_funcs
}
}
})
]
},
plugins: [
new ESLintLoader({
fix: true,
files: ['**/*.js', '**/*.mjs', '**/*.cjs']
}),
new NodemonPlugin({
// If using more than one entry, you can specify
// which output file will be restarted.
script: './bin/server.js',
// What to watch.
watch: path.resolve('./bin'),
// Arguments to pass to the script being watched.
args: ['demo'],
// Node arguments.
// nodeArgs: ['--debug=9222'],
// Files to ignore.
ignore: ['*.js.map'],
// Extensions to watch.
ext: 'js,njk,json,mjs,cjs',
// Unlike the cli option, delay here is in milliseconds (also note that it's a string).
// Here's 1 second delay:
delay: '1000',
// Detailed log.
verbose: true,
// Environment variables to pass to the script to be restarted
env: {
NODE_ENV: 'development'
},
nodemonConfig: {
legacyWatch: true
}
})
],
resolve: {
extensions: ['*', '.js', '.mjs', '.cjs']
}
};