forked from jhipster/jhipster-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
41 lines (39 loc) · 1.1 KB
/
webpack.config.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
const _ = require('lodash');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const { tokens } = require('./lib/dsl/lexer');
const allTokenTypeNames = _.mapValues(tokens, tokenType => tokenType.name);
module.exports = {
mode: 'production',
entry: './lib/dsl/exports.js',
output: {
path: path.resolve(__dirname, './dist/'),
filename: 'jdl-core.min.js',
library: 'jdlCore',
libraryTarget: 'umd',
// https://github.com/webpack/webpack/issues/6784
globalObject: "typeof self !== 'undefined' ? self : this"
},
externals: {
// https://webpack.js.org/guides/author-libraries/#externalize-lodash
lodash: {
commonjs: 'lodash',
commonjs2: 'lodash',
amd: 'lodash',
root: '_'
}
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
mangle: {
// Avoid mangling TokenType names, this can break Chevrotain initialization phase
// due to reliance on Function.protoType.toString.
reserved: allTokenTypeNames
}
}
})
]
}
};