-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.ts
67 lines (62 loc) · 2.55 KB
/
webpack.config.ts
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
/*
* CivBuddy - A calculator app for players of Francis Tresham's original Civilization board game (1980)
* Copyright (C) 2012-2023 Thomas Jensen
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License, version 3, as published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
import CopyWebpackPlugin from 'copy-webpack-plugin';
import * as execa from 'execa';
import * as path from 'path';
import * as webpack from 'webpack';
const VersionFile = require('webpack-version-file-plugin');
const gitHash: string = execa.sync('git', ['rev-parse', '--short', 'HEAD']).stdout;
const gitNumCommits: number = Number(execa.sync('git', ['rev-list', 'HEAD', '--count']).stdout);
const gitDirty: boolean = execa.sync('git', ['status', '-s', '-uall']).stdout.length > 0;
const config: webpack.Configuration = {
entry: './src/ts/main.ts',
output: {
path: path.resolve(__dirname, 'build/dist'),
filename: 'js/civbuddy.js',
libraryTarget: 'var',
library: 'CivBuddy'
},
devtool: 'source-map',
mode: 'development',
module: {
rules: [
{ test: /\.ts$/, use: 'ts-loader' }
]
},
plugins: [
new VersionFile({
packageFile: path.resolve(__dirname, 'package.json'),
template: path.resolve(__dirname, 'version.ejs'),
outputFile: path.resolve(__dirname, 'src/ts/framework/version.json'),
extras: {
'githash': gitHash,
'gitNumCommits': gitNumCommits,
'timestamp': Date.now(),
'dirty': gitDirty
}
}),
new CopyWebpackPlugin([
{ from: 'resources', ignore: ['**/*.html'] },
{ from: 'node_modules/bootstrap/dist/js/bootstrap.min.js', to: 'js' },
{ from: 'node_modules/open-iconic/font/css/open-iconic-bootstrap.min.css', to: 'css' },
{ from: 'node_modules/open-iconic/font/fonts', to: 'fonts' },
{ from: 'build/l20n/l20n.min.js', to: 'js' }
], {
copyUnmodified: false
})
],
resolve: {
extensions: ['.ts', '.js']
}
};
export default config;