This repository has been archived by the owner on Jun 7, 2022. It is now read-only.
forked from offeringofpie/pie-liner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
130 lines (128 loc) · 3.09 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
120
121
122
123
124
125
126
127
128
129
130
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const clip = require('clipboardy');
const NotifierPlugin = require('webpack-notifier');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const WebpackBar = require('webpackbar');
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: argv.mode || 'development',
entry: {
index: './src/index.js'
},
output: {
filename: '[name].[hash:3].js',
path: path.resolve(__dirname, 'docs'),
publicPath: argv.mode == 'production' ? './' : '/'
},
resolve: {
extensions: ['.ts', '.js', '.jsx', '.tsx', '.css'],
modules: ['node_modules'],
symlinks: false,
cacheWithContext: false,
alias: {
'@': path.join(__dirname, 'src')
}
},
module: {
rules: [
{
test: /\.tsx?$/,
use: ['ts-loader', 'import-glob'],
exclude: /node_modules/
},
{
enforce: 'pre',
test: /\.css$/,
use: [
{
loader: 'css-loader',
options: {
modules: true,
import: true,
sourceMap: argv.mode === 'production',
localIdentName:
argv.mode === 'production'
? '[contentHash:3]-[emoji:3]'
: '[local]__[contentHash:3]'
}
},
'postcss-loader',
'typed-css-modules-loader'
]
},
{
test: __dirname + '/src/index.html',
use: ['html-loader']
}
]
},
plugins: [
new WebpackBar(),
new NotifierPlugin({
alwaysNotify: true,
skipFirstNotification: true
}),
new MiniCssExtractPlugin({
filename: '[name].css'
}),
new HtmlWebpackPlugin({
template: 'src/index.html',
meta: {
viewport: 'width=device-width, initial-scale=1'
}
})
],
performance: {
hints: false
},
optimization: {
minimizer: [
new OptimizeCSSAssetsPlugin(),
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6
}
})
]
},
node: {
setImmediate: false,
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
},
stats: stats,
devServer: {
stats: stats,
port: 4000,
historyApiFallback: true,
after: function(app, server) {
clip.writeSync('http://localhost:4000/');
}
},
devtool: argv.mode === 'production' ? false : 'inline-source-map'
};
};