-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore.config.js
120 lines (109 loc) · 3.23 KB
/
core.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
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
const config = {
entry: {
style: './core/build/scss/style.scss',
select: './core/build/ts/select.ts',
},
output: {
path: path.resolve(__dirname, 'core/static/'),
filename: 'js/[name].min.js',
},
module: {
rules: [
{
test: /\.ts$/,
include: path.resolve(__dirname, 'core/build/ts/'),
exclude: [],
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
plugins: ['@babel/plugin-transform-runtime'],
},
},
'ts-loader',
],
},
{
test: /\.scss/,
include: path.resolve(__dirname, 'core/build/scss/'),
exclude: [],
use: [MiniCssExtractPlugin.loader, 'css-loader', 'postcss-loader', 'sass-loader'],
},
{
test: /\.(woff|woff2)$/,
type: 'asset/resource',
generator: {
filename: 'fonts/[hash][ext][query]',
},
},
],
},
performance: {
maxEntrypointSize: 1024000,
maxAssetSize: 1024000,
},
stats: {
colors: true,
hash: false,
version: false,
timings: false,
assets: true,
modules: false,
entrypoints: false,
builtAt: false,
},
plugins: [
new MiniCssExtractPlugin({
filename: './css/[name].min.css',
}),
new RemoveEmptyScriptsPlugin({
silent: true,
}),
],
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
config.devtool = 'inline-source-map';
}
if (argv.mode === 'production') {
config.optimization = {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
output: {
comments: false,
},
},
extractComments: false,
}),
new CssMinimizerPlugin({
minimizerOptions: {
preset: [
'default',
{
discardComments: { removeAll: true },
},
],
},
}),
],
};
if (!process.env.CI) {
config.plugins = [
...config.plugins,
new webpack.ProgressPlugin({
percentBy: 'entries',
}),
];
}
}
return config;
};