-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.config.cjs
68 lines (66 loc) · 1.98 KB
/
webpack.config.cjs
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
65
66
67
68
'use strict';
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const exec = require('child_process');
const build_pkg = require('./package.json');
const build_git = exec.execSync('git rev-parse --short HEAD').toString();
const now = new Date;
const build_date = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`;
module.exports = (env, argv) => ({
mode: 'none',
context: __dirname,
entry: {
index: path.resolve(__dirname, 'www', 'index.js')
},
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist', 'www'),
publicPath: '/xc-score/'
},
resolve: {
modules: ['node_modules'],
alias: {
'igc-xc-score': path.resolve(__dirname, 'index.js'),
jquery: 'jquery/dist/jquery.min.js'
}
},
devtool: argv.mode == 'development' ? 'eval-source-map' : undefined,
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}),
new webpack.DefinePlugin({
__BUILD_GIT__: JSON.stringify(build_git),
__BUILD_PKG__: JSON.stringify(build_pkg),
__BUILD_DATE__: JSON.stringify(build_date),
__DEBUG__: JSON.stringify(argv.mode == 'development')
}),
new CopyPlugin({
patterns: [
{ from: 'www/index.html', to: 'index.html' },
{ from: 'www/pacman.svg', to: 'pacman.svg' }
]
})
],
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
optimization: {
usedExports: true
},
devServer: {
static: {
directory: path.join(__dirname, 'dist', 'www'),
},
compress: true,
port: 9000
}
});