forked from Platform-OS/platformos-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
93 lines (88 loc) · 2.13 KB
/
webpack.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
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
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackRequireFrom = require('webpack-require-from');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const BUILD_DIR = path.join(__dirname, process.env.npm_package_config_build_dir);
const production = process.env.NODE_ENV === 'production';
const plugins = [
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css'
}),
new WebpackRequireFrom({
variableName: 'window.__CONTEXT__.cdnUrl'
})
];
const config = {
entry: {
app: './src/app',
raven: './src/raven',
critical: './src/critical',
webfonts: './src/webfonts'
},
output: {
filename: '[name].js',
chunkFilename: '[name].[chunkhash:3].js',
publicPath: '',
path: BUILD_DIR
},
bail: true,
stats: {
modules: false,
hash: false,
assetsSort: '!size',
children: false
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader?retainLines=true&cacheDirectory'
},
{
test: /(\.css|\.scss)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader?url=false', 'postcss-loader', 'sass-loader']
},
{
test: /\.gif$/,
use: ['file-loader?name=[name].gif']
},
{
test: /\.(eot|ttf|otf|svg|woff(2))?$/,
loader: 'file-loader?name=fonts/[name].[ext]'
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
parallel: true,
uglifyOptions: {
warnings: false,
parse: {},
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
},
mangle: true,
output: {
comments: false
},
toplevel: false,
nameCache: null,
ie8: false,
keep_fnames: false
}
})
]
},
plugins: plugins,
mode: production ? 'production' : 'development'
};
module.exports = config;