-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
65 lines (65 loc) · 1.65 KB
/
webpack.prod.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
/*
* Created by charlotte.wang([email protected]) on 2019/01/25
* Last Modified by charlotte.wang on 2019/01/25
* Copyright (c) 2019 Gago Ltd.
*
* HISTORY:
* Date By Comments
* ---------- --------- -------------------------------------------------------
*/
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HappyPack = require("happypack");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = {
name: "app",
mode: "production",
dependencies: ["vendors"],
entry: {
app: ["./src/app/app.tsx"],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "js/[name].bundle.js"
},
devtool: "source-map",
resolve: {
extensions: [".js", ".jsx", ".json", ".ts", ".tsx"]
},
module: {
rules: [{
test: /\.(ts|tsx)$/,
loader: "ts-loader",
include: [path.resolve("src")],
exclude: /node_modules/
},
{
test: /\.js$/,
use: "happypack/loader?id=js-pack",
include: [path.resolve("src")],
exclude: /node_modules/
},
{
enforce: "pre",
test: /\.js$/,
loader: "source-map-loader"
}
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "dist", "index.html"),
}),
new HappyPack({
id: "js-pack",
threads: 4,
loaders: ["babel-loader?cacheDirectory=true"]
}),
new webpack.DllReferencePlugin({
// context: __dirname,
manifest: require("./dist/vendors-manifest.json")
}),
new BundleAnalyzerPlugin()
]
};