-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.prod.js
129 lines (124 loc) · 3.93 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import path from 'path';
import webpack from 'webpack';
import WebpackMd5Hash from 'webpack-md5-hash'
import HtmlWebpackPlugin from 'html-webpack-plugin';
import UglifyJsPlugin from 'uglifyjs-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin';
import ScriptExtHtmlWebpackPlugin from 'script-ext-html-webpack-plugin';
const GLOBALS = {
'process.env.NODE_ENV': JSON.stringify('production'),
__DEV__: false
};
export default {
mode: 'production',
cache: true,
devtool: 'source-map',
entry: path.resolve(__dirname, 'src/index.js'),
target: 'web',
output: {
path: path.resolve(__dirname, "dist"),
publicPath: '/dashboard/',
filename: '[name].[chunkhash].js'
},
resolve: {
extensions: ['*', '.js', '.elm']
},
resolveLoader: {
modules: [path.resolve(__dirname, 'tools'), 'node_modules']
},
plugins: [
new WebpackMd5Hash(),
new webpack.DefinePlugin(GLOBALS),
new MiniCssExtractPlugin({
filename: "[name].[contenthash].css"
}),
new HtmlWebpackPlugin({
template: 'src/index.ejs',
favicon: 'src/favicon.ico',
minify: {
removeComments: false,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
},
inject: 'head'
}),
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'defer'
}),
new webpack.optimize.OccurrenceOrderPlugin(),
],
optimization: {
concatenateModules: true,
minimizer: [
new OptimizeCssAssetsPlugin(),
new UglifyJsPlugin({ sourceMap: true, parallel: true }),
],
splitChunks: {
cacheGroups: {
default: false,
commons: {
// Do not include nexosis-styles as a vendor css file.
test: /[\\/]node_modules[\\/](?!nexosis)/,
name: 'vendor',
chunks: 'all'
}
}
}
},
module: {
rules: [
{
loader: 'babel-loader',
test: /\.js&/,
exclude: [/elm-stuff/, /node_modules/],
},
{
test: /\.elm$/,
exclude: [/elm-stuff/, /node_modules/],
loader: 'elm-webpack-loader?verbose=true&warn=true&debug=false&pathToMake=' + __dirname + '/node_modules/.bin/elm-make&cwd=' + __dirname + '&forceWatch=false'
},
{
test: /(\.css|\.scss|\.sass)$/,
use: [
MiniCssExtractPlugin.loader,
"css-loader",
{
loader: "postcss-loader",
options: {
plugins: () => [require('autoprefixer')]
}
},
"sass-loader"
]
},
{
type: 'javascript/auto',
test: /(config)\.json$/,
use: [
{
loader: 'file-loader',
options: { name: '[name].[ext]' }
}
, 'config-loader'
]
},
{
test: /(\.md)$/,
use: [
{
loader: 'file-loader',
options: { name: 'docs/[name].[ext]' }
}
]
}
]
}
};