-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.ts
46 lines (42 loc) · 1021 Bytes
/
webpack.prod.ts
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
import { merge } from 'webpack-merge'
import path from 'path'
import common from './webpack.common'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import process from 'process'
import glob from 'glob'
import 'webpack-dev-server'
import { PurgeCSSPlugin } from 'purgecss-webpack-plugin'
const PATHS = {
src: path.join(__dirname, 'src')
}
const config = merge(common, {
mode: 'production',
devtool: false,
output: {
filename: '[name][contenthash].js',
path: path.join(__dirname, './public'),
clean: true
},
optimization: {
nodeEnv: process.env.NODE_ENV,
minimize: true
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
// @ts-ignore: Unreachable code error
new PurgeCSSPlugin({
paths: glob.sync(`${PATHS.src}/**/*`, { nodir: true })
})
],
module: {
rules: [
{
test: /\.(sa|sc|c)ss$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
}
]
}
})
export default config