-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
88 lines (87 loc) · 2.66 KB
/
webpack.config.prod.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
// jscs:disable
const path = require("path");
const webpack = require("webpack");
const AssetsPlugin = require("assets-webpack-plugin");
const ExtractPlugin = require("extract-text-webpack-plugin");
const OccurrenceOrderPlugin = new webpack.optimize.OccurrenceOrderPlugin();
module.exports = {
devtool: false,
entry: {
bundle: [
"./src/index.js",
"./public/styles/index.less"
],
vendor: [
"react",
"react-dom",
"animate.css/animate.min.css",
"semantic-ui-css/semantic.min.css"
]
},
output: {
path: path.join(__dirname, "build/public"),
filename: "[name]_[hash].js",
chunkFilename: "[id].chunk_[hash].js",
publicPath: "/build/public/"
},
plugins: [
OccurrenceOrderPlugin,
new webpack.optimize.CommonsChunkPlugin({
name: "vendor",
filename: "vendor_[hash].js",
minChunks: 2
}),
new AssetsPlugin({filename: "assets.json"}),
new webpack.optimize.UglifyJsPlugin({
compress: {
unused: true,
dead_code: true,
warnings: false,
screw_ie8: true,
}
}),
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify("production"),
"__DEV__": false,
}),
new ExtractPlugin("[name].css")
],
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: path.join(__dirname, "node_modules"),
use: "babel-loader",
include: path.join(__dirname, "src")
},
{
test: /\.(less|css)$/,
use: ExtractPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader",
options: {
minimize: true,
camelCase: true
}
},
{
loader: "less-loader",
options: {
minimize: true,
importLoaders: 1,
camelCase: true,
strictMath: true
}
}
]
})
},
{
test: /\.(svg|png|woff|woff2|jpg|gif|ttf|eot)$/,
use: "url-loader"
}
]
}
};