-
Notifications
You must be signed in to change notification settings - Fork 24
/
webpack.config.js
112 lines (111 loc) · 2.46 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
const HtmlWebpackPlugin = require('html-webpack-plugin'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
TerserPlugin = require('terser-webpack-plugin'),
path = require('path'),
webpack = require('webpack');
module.exports = {
entry: {
main: ['babel-polyfill', path.resolve(__dirname, 'src/app.jsx')],
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
query: { compact: false },
include: [
path.resolve(__dirname, 'src'),
path.resolve(
__dirname,
'node_modules/@acoustic-content-sdk/wch-flux-sdk'
),
],
},
{
test: /\.s?css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: ['css-loader', 'sass-loader'],
}),
},
{
test: /\.(gif|png|jpg|woff2?|)$/,
loader: 'url-loader?limit=8192&name=[name].[ext]',
},
{
test: /\.svg$/,
include: [/styles[\\/]layouts[\\/]images/],
loader: 'file-loader?name=[name].[ext]',
},
{
test: /\.svg$/,
exclude: [/styles[\\/]layouts[\\/]images/],
loader: 'svg-sprite-loader',
},
],
},
// devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist/assets'),
filename: '[name].js',
chunkFilename: '[name].js',
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules/,
name: 'vendors',
enforce: true,
chunks: 'all',
},
},
},
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true, // Must be set to true if using source-maps in production
terserOptions: {
ecma: undefined,
warnings: false,
parse: {},
compress: {},
mangle: true, // Note `mangle.properties` is `false` by default.
module: false,
output: null,
toplevel: false,
nameCache: null,
ie8: true,
keep_classnames: undefined,
keep_fnames: false,
safari10: true,
},
}),
],
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
},
}),
new webpack.NoEmitOnErrorsPlugin(),
new ExtractTextPlugin('[name].css'),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/index.html'),
}),
],
resolve: {
alias: {
styles: path.resolve(__dirname, './styles'),
},
extensions: ['.js', '.jsx'],
},
devServer: {
contentBase: path.join(__dirname, 'dist/assets'),
historyApiFallback: true,
https: false,
},
};