-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.prod.js
102 lines (99 loc) · 2.55 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var WebpackMd5Hash = require("webpack-md5-hash");
var Visualizer = require("webpack-visualizer-plugin");
const GLOBALS = {
"process.env.NODE_ENV": JSON.stringify("production"),
__DEV__: false
};
module.exports = {
devtool: "cheap-module-source-map", //source-map
entry: "./src/index.js",
target: "web",
output: {
path: __dirname + "/dist", // Note: Physical files are only output by the production build task `npm run build`.
publicPath: "/",
filename: "assets/js/bundle.js"
},
plugins: [
new WebpackMd5Hash(),
new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.DefinePlugin(GLOBALS),
new ExtractTextPlugin("assets/css/main.css"),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
}),
new Visualizer(),
new webpack.ContextReplacementPlugin(
/highlight\.js\/lib\/languages$/,
new RegExp(`^./(${["javascript", "css", "bash"].join("|")})$`)
),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false,
drop_console: false
}
}),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
],
module: {
rules: [
{
test: /\.js$/,
// exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["env"]
}
}
},
{
test: /(\.css|\.scss)$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: ["css-loader", "sass-loader"]
})
},
{
test: /\.(woff|woff2|eot|ttf|otf|)(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
use: {
loader: "url-loader",
options: {
limit: 10000,
name: "assets/font/[name].[hash:8].[ext]"
}
}
},
{
test: /\.svg(\?v=[a-z0-9]\.[a-z0-9]\.[a-z0-9])?$/,
use: {
loader: "url-loader",
options: {
limit: 10000,
name: "assets/img/[name].[hash:8].[ext]"
}
}
},
{
test: /\.(png|jpe?g|gif|ico)$/,
use: {
loader: "file-loader",
options: {
name: "assets/img/[name].[ext]"
}
}
},
{
test: /\.ico$/,
loader: "file?name=[name].[ext]"
},
{
test: /manifest.json$/,
loader: "file-loader?name=manifest.json!web-app-manifest-loader"
}
]
}
};