-
Notifications
You must be signed in to change notification settings - Fork 21
/
webpack.js
68 lines (66 loc) · 1.89 KB
/
webpack.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
const path = require("path");
const UglifyJSPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
.BundleAnalyzerPlugin;
const process = require("global/process");
const ANALYZE = false;
const PROD = process.env.NODE_ENV === "production";
const OUTPUT_DIR = "lib/";
module.exports = {
mode: PROD ? "production" : "development",
entry: "./src/iotex-antenna.browser.ts",
output: {
filename: PROD
? "iotex-antenna.browser.min.js"
: "iotex-antenna.browser.js",
path: path.resolve(__dirname, OUTPUT_DIR)
},
devtool: "source-map",
module: {
rules: [
{
test: /(\.js|\.ts|\.tsx|\.jsx)$/,
use: ["cache-loader", "babel-loader"],
include: path.resolve("src")
},
{ test: /\.tsx?$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: "babel-loader",
options: require("./babel.config")
}
}
]
},
resolve: {
// options for resolving module requests
// (does not apply to resolving to loaders)
modules: ["node_modules", path.resolve(__dirname, "src")],
// directories where to look for modules
extensions: [".js", ".json", ".jsx", ".ts", ".tsx"],
// extensions that are used
alias: {}
/* Alternative alias syntax (click to show) */
/* Advanced resolve configuration (click to show) */
},
plugins: [
...(ANALYZE ? [new BundleAnalyzerPlugin()] : []),
...(PROD
? [
new UglifyJSPlugin({
cache: true,
parallel: true
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
}
})
]
: [])
]
};