-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
49 lines (45 loc) · 1.41 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
const path = require('path');
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
let pkg = require('./package.json');
const fs = require('fs');
module.exports = {
plugins: [
new WebpackShellPluginNext({
onBuildEnd: {
scripts: [
() => {
const scriptHeader = fs.readFileSync('src/scriptHeader.js', 'utf-8');
const builtScriptContents = fs.readFileSync('dist/index.js', 'utf-8');
const updatedHeader = scriptHeader
.replace('__VERSION__', pkg.version)
.replace('__DESCRIPTION__', pkg.description);
const userscriptContents = updatedHeader + "\n\n" + builtScriptContents;
fs.writeFileSync('dist/userscript.js', userscriptContents);
},
'rm dist/index.js'
],
blocking: true,
parallel: false
}
})
],
entry: {
index: './src/index.js'
},
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
minimize: false
},
mode: 'production',
module: {
rules: [
{
test: /\.(css|svg|html)$/i,
use: 'raw-loader',
},
],
}
};