This repository has been archived by the owner on Jun 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwebpack.config.js
105 lines (97 loc) · 2.11 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
99
100
101
102
103
104
105
const webpack = require('webpack');
var nodeExternals = require('webpack-node-externals');
const NodemonPlugin = require('nodemon-webpack-plugin');
const path = require('path');
const CompressionPlugin = require('compression-webpack-plugin');
module.exports = [
{
entry: __dirname + '/client/index.js',
output: {
path: __dirname + '/client/dist',
publicPath: '/dist/',
filename: 'client_bundle.js',
},
target: 'web',
devtool: 'source-map',
plugins: [new CompressionPlugin({ compressionOptions: { level: 9 } })],
module: {
rules: [
{
test: /\.css$/i,
exclude: /node_modules/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.html$/i,
exclude: /node_modules/,
loader: 'html-loader',
},
{
test: /\.js$/,
exclude: /node_modules/,
},
{
test: /\.(png|jpg|gif|webm|mp3)$/i,
use: [
{
loader: 'url-loader',
},
],
},
{
test: /\.svg$/,
use: [
{
loader: 'svg-url-loader',
options: {
limit: 10000,
},
},
],
},
],
},
},
{
entry: __dirname + '/server/server.js',
output: {
path: __dirname + '/server/dist',
publicPath: '/server/dist/',
filename: 'server_bundle.js',
},
target: 'node',
externals: [nodeExternals()],
devtool: 'source-map',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
},
],
},
plugins: [
new webpack.BannerPlugin({
banner: 'require("source-map-support").install();',
raw: true,
entryOnly: false,
}),
new NodemonPlugin({
// If using more than one entry, you can specify
// which output file will be restarted.
script: './server/dist/server_bundle.js',
// What to watch.
watch: [path.resolve('./server'), path.resolve('./client')],
// Files to ignore.
ignore: ['*.js.map'],
// Extensions to watch.
ext: 'js,html,css',
// Unlike the cli option, delay here is in milliseconds (also note that it's a string).
// Here's 1 second delay:
delay: '100',
// Detailed log.
verbose: false,
}), // Dong
],
},
];