-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
43 lines (41 loc) · 1.23 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
const path = require('path');
const webpack = require('webpack');
const packageJson = require('./package.json');
const { writeFileSync } = require('fs');
module.exports = (env, argv) => {
const isProd = argv.mode === 'production';
const localPath = path.join(path.resolve(__dirname), 'pkg', 'userscript.user.js');
const localInclude = isProd
? ''
: `\n// @require file:${localPath}`;
const banner = `// ==UserScript==
// @name Farkle-${isProd ? 'production' : 'development'}
// @version ${packageJson.version}
// @match https://cardgames.io/farkle*${localInclude}
// ==/UserScript==`;
if (!isProd) {
writeFileSync('./pkg/userscript.development.user.js', banner);
}
const commonConfig = {
mode: 'development',
entry: './userscript/entry.js',
optimization: {
minimize: false
},
output: {
path: path.resolve(__dirname, 'pkg'),
filename: 'userscript.user.js',
},
plugins: [
new webpack.DefinePlugin({
SERVER: JSON.stringify(isProd ? 'https://domsleee.github.io/farkle-ai' : 'http://127.0.0.1:8080')
}),
new webpack.BannerPlugin({
banner,
entryOnly: true,
raw: true
})
]
};
return commonConfig;
};