-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (90 loc) · 1.8 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
// webpack.config.js
// =================
"use strict";
const fs = require('fs');
const path = require('path');
const plugins = require('./webpack/plugins');
const shims = require('./webpack/shims');
const htmlOptions = require('./webpack/htmlOptions');
const paths = require('./webpack/paths');
const rules = require('./webpack/rules');
// TODO:
// =====
// * Autoprefixer
const mode = (
process.env.NODE_ENV == "production" ? "production"
: "development"
);
const devtool = (
mode == "production" ? "source-map"
: "inline-source-map"
);
const resolve = {
mainFiles: ['index', 'index.view'],
alias: paths.aliases,
};
const serverConfig = {//{{{
target: "node",
entry: {
main: [
...shims,
"./Server/main",
],
},
mode,
resolve,
plugins: [
new plugins.CleanWebpackPlugin(),
],
output: {
filename: "[name].js",
path: paths.dists.server,
},
module: {
rules: rules.server,
},
externals: [plugins.nodeExternals()],
};//}}}
const clientConfig = {//{{{
target: "web",
devtool,
entry: {
index: [
...shims,
"@babel/polyfill",
"./Client/main",
],
},
mode,
resolve,
plugins: [
new plugins.CleanWebpackPlugin(),
new plugins.HtmlWebpackPlugin(htmlOptions),
new plugins.HtmlWebpackPugPlugin({
adjustIndent: true,
pretty: true,
}),
],
output: {
filename: "[name].[contenthash].js",
path: paths.dists.client,
publicPath: "/",
},
module: {
rules: rules.client,
},
optimization: {
moduleIds: 'hashed',
runtimeChunk: 'single',
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
},
},
},
};//}}}
module.exports = [serverConfig, clientConfig];