-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.ts
54 lines (52 loc) · 1.28 KB
/
webpack.config.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
47
48
49
50
51
52
53
54
import * as webpack from 'webpack'
import { Configuration } from 'webpack'
import banner from './scripts/banner'
import metadata from './monkey.config'
import LimitChunkCountPlugin = webpack.optimize.LimitChunkCountPlugin
import BannerPlugin = webpack.BannerPlugin
import TerserPlugin from 'terser-webpack-plugin'
// noinspection JSUnusedGlobalSymbols
export default {
entry: './src/index.ts',
output: {
filename: metadata.name.toLowerCase().replace(' ', '-') + '.user.js'
},
mode: 'none',
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: false,
format: {
comments: (node, comment) => comment.type === 'comment1'
&& /(^\s==\/?UserScript==)|(^\s@.+\s+.+$)|(^\s$)/.test(comment.value)
}
}
})
]
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader'
},
{
test: /\.s[ac]ss$/i,
use: ['to-string-loader', 'css-loader', 'postcss-loader', 'sass-loader']
},
{
test: /\.(png|jpg|gif)$/,
type: 'asset/inline'
}
]
},
plugins: [
new LimitChunkCountPlugin({ maxChunks: 1 }),
new BannerPlugin({
raw: true,
banner: banner()
})
]
} as Configuration