-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
119 lines (117 loc) · 2.74 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
113
114
115
116
117
118
119
const path = require('path');
const webpack = require('webpack');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const clip = require('clipboardy');
const NotifierPlugin = require('webpack-notifier');
const WebpackBar = require('webpackbar');
const TerserPlugin = require('terser-webpack-plugin');
const stats = {
all: false,
assets: true,
cachedAssets: true,
children: false,
chunks: false,
entrypoints: true,
errorDetails: true,
errors: true,
hash: true,
modules: false,
performance: true,
publicPath: true,
timings: true,
warnings: false,
exclude: [
'node_modules'
]
};
module.exports = (env, argv) => {
return {
mode: 'development',
entry: ['./src/main.js'],
output: {
filename: 'index.min.js',
path: path.resolve(__dirname, 'docs')
},
resolve: {
extensions: ['.js', '.json', '.css']
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: '/node_modules/'
}, {
test: /\.css$/,
use: [
{ loader: MiniCssExtractPlugin.loader },
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
}, {
test: /\.(?:png|jpg|svg|gif)$/,
loader: 'file-loader',
options: {
name: './img/[name].[ext]'
}
}
]
},
plugins: [
new WebpackBar(),
new NotifierPlugin({
title: 'Minesweeper',
alwaysNotify: true,
skipFirstNotification: true
}),
new MiniCssExtractPlugin({
filename: 'style.min.css',
outputPath: 'dist'
}),
new HtmlWebpackPlugin({
template: __dirname + '/src/index.ejs',
inject: 'body'
})
],
devtool: '#source-map',
performance: { hints: false },
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
discardComments: {
removeAll: true
},
discardEmpty: true,
discardOverridden: true
}
}),
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6,
},
})
]
},
stats: stats,
devServer: {
stats: stats,
port: 4000,
historyApiFallback: true,
after: function(app, server) {
clip.writeSync('http://localhost:4000/');
}
},
node: {
setImmediate: false,
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
}