-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·93 lines (87 loc) · 2.21 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
/* eslint comma-dangle: 0 */
const webpack = require("webpack"); // eslint-disable-line no-unused-vars
const path = require("path");
const nodeEnv = process.env.NODE_ENV || "development";
const isProduction = nodeEnv === "production";
const commonConfig = require("./utils/webpack.common.js");
const prodConfig = require("./utils/webpack.prod.js");
const devConfig = require("./utils/webpack.dev.js");
const jsSourcePath = path.join(__dirname, "./source/js");
const buildPath = path.join(__dirname, "./build");
const sourcePath = path.join(__dirname, "./source");
// Common plugins & rules
const plugins = [...commonConfig.plugins];
const rules = [...commonConfig.rules];
let mode;
if (isProduction) {
// Production plugins & rules
plugins.push(...prodConfig.plugins);
rules.push(...prodConfig.rules);
mode = prodConfig.mode;
} else {
// Development plugins & rules
plugins.push(...devConfig.plugins);
rules.push(...devConfig.rules);
mode = devConfig.mode;
}
module.exports = {
mode: mode,
devtool: isProduction ? false : "source-map",
context: jsSourcePath,
entry: {
app: "./index.js",
vendor: ["lazysizes", path.join(__dirname, "node_modules/lazysizes/plugins/bgset/ls.bgset.js")]
},
output: {
path: buildPath,
publicPath: "/",
filename: "[name].js",
libraryTarget: 'umd',
globalObject: "this",
sourcePrefix: ''
},
amd: {
// Enable webpack-friendly use of require in Cesium
toUrlUndefined: true
},
module: {
rules,
},
resolve: {
extensions: [
".webpack-loader.js",
".web-loader.js",
".loader.js",
".js",
".jsx",
],
modules: [path.resolve(__dirname, "node_modules"), jsSourcePath],
fallback: {
fs: false
}
},
plugins,
devServer: {
contentBase: isProduction ? buildPath : sourcePath,
historyApiFallback: true,
port: 3000,
compress: isProduction,
inline: !isProduction,
hot: !isProduction,
host: "0.0.0.0",
stats: {
assets: true,
children: false,
chunks: false,
hash: false,
modules: false,
publicPath: false,
timings: true,
version: false,
warnings: true,
colors: {
green: "\u001b[32m",
},
},
},
};