-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
64 lines (59 loc) · 1.72 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
'use strict';
// spell-checker:ignore chunkhash devtool
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const PKG = require('./package.json');
// ToDO: generate 'library' from PKG.name instead of using PKG.browserModuleName (and get rid of that property)
module.exports = {
mode: 'development',
context: __dirname,
devtool: 'source-map',
entry: {
[`${PKG.name}.user`]: path.resolve(__dirname, PKG.main),
[`${PKG.name}.min.user`]: path.resolve(__dirname, PKG.main),
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
hashFunction: 'sha256', // ref: https://stackoverflow.com/a/73027407/43774 @@ <https://archive.is/8KniB>
library: PKG.browserModuleName,
libraryTarget: 'umd',
},
optimization: {
minimize: true,
minimizer: [ new TerserPlugin({
include: /[.]min([.]user)?[.]js$/i,
sourceMap: true,
terserOptions: {
output: {
ascii_only: true,
comments: /@license/i
} // ref: <https://stackoverflow.com/a/57362733/43774>
}
})]
},
module: {
rules: [
{
test: /[.]css$/,
use: ["style-loader", "css-loader"],
},
{
test: /[.]js$/,
use: "babel-loader",
// exclude: /(bower_components|node_modules)/,
},
],
},
performance: {
hints: false
},
plugins: [
new webpack.BannerPlugin({
banner:
// `${PKG.name} (as ${PKG.browserModuleName}; ==UserScript==) ${PKG.version} [(hash)] ${PKG.homepage} @license ${PKG.license}`
`${PKG.name} (as ${PKG.browserModuleName}; ==UserScript==) ${PKG.version} ${PKG.homepage} @license ${PKG.license}`
})
]
};