-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack_build.js
30 lines (28 loc) · 1013 Bytes
/
webpack_build.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
const baseConfig = require('./webpack_common');
const path = require('path');
const merge = require('webpack-merge');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const webpack = require('webpack');
const { gitDescribeSync } = require('git-describe');
const { execSync } = require('child_process');
const gitInfo = gitDescribeSync();
const lastCommitDate = execSync('git show -s --format=%ci ' + gitInfo.hash).toString();
module.exports = merge(baseConfig, {
output: {
path: [__dirname, 'dist'].join(path.sep),
filename: '[name].[hash].js'
},
target: 'web',
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production"),
WEBSOCKET_URI: process.env.WEBSOCKET_URI ? JSON.stringify(process.env.WEBSOCKET_URI) : null,
CLIENT_VERSION: JSON.stringify(gitInfo.raw),
LAST_COMMIT_DATE: JSON.stringify(lastCommitDate)
}
}),
new UglifyJSPlugin(),
],
mode: 'production'
});