-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.skpm.config.js
45 lines (39 loc) · 1012 Bytes
/
webpack.skpm.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
const webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin')
module.exports = function (config, isPluginCommand) {
const isProduction = process.env.NODE_ENV === 'production'
for (const rule of config.module.rules) {
if (rule.use.loader === '@skpm/file-loader') {
if (!rule.exclude) {
rule.exclude = /node_modules|template\//
}
}
}
config.module.rules.push({
test: /\.tsx?$/,
exclude: /node_modules|template\//,
loader: 'ts-loader'
})
if (!config.resolve) {
config.resolve = {
extensions: []
}
}
config.resolve.extensions = [...config.resolve.extensions, '.ts', '.tsx']
// transformations for production (publish)
if (isProduction) {
config.mode = 'production'
config.plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true
})
)
config.optimization = {
minimizer: [
new TerserPlugin({
test: /\.j|ts($|\?)/i
})
]
}
}
}