-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.cjs
60 lines (58 loc) · 1.74 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
'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 build_date = exec.execSync('date -u +"%Y-%m-%d"').toString();
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
}
});