-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.prod.js
52 lines (47 loc) · 1.17 KB
/
webpack.prod.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
44
45
46
47
48
49
50
51
52
// @ts-check
const path = require('path');
const fs = require('fs');
const nodeExternals = require('webpack-node-externals');
const webpack = require('webpack');
const alias = {};
const dir = path.join(__dirname, 'src');
fs.readdirSync(dir)
.filter(filename => fs.statSync(path.join(dir, filename)).isDirectory())
.forEach(filename => {
const absPath = path.join(dir, filename);
const aliasPath = path.join('@eolian', filename);
console.log(`\t${aliasPath} -> ${absPath}`);
alias[aliasPath] = absPath;
});
let commitHash = require('child_process')
.execSync('git log -1 --date=format:"%d.%m.%y" --format="%ad"')
.toString()
.trim();
module.exports = {
mode: 'production',
entry: path.join(dir, 'app.ts'),
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
plugins: [
new webpack.DefinePlugin({
__COMMIT_DATE__: JSON.stringify(commitHash)
})
],
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: alias,
},
target: 'node',
externals: [nodeExternals()],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};