-
Notifications
You must be signed in to change notification settings - Fork 267
/
webpack.common.config.js
58 lines (55 loc) · 1.79 KB
/
webpack.common.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// This is the base webpack config that other configs build upon
var webpack = require('webpack');
var SDK_VERSION = require('./package.json').version;
var babelOptions = {
configFile: false, // do not load from babel.config.js
babelrc: false, // do not load from .babelrc
presets: [
'@babel/preset-typescript'
],
plugins: [],
sourceType: 'unambiguous',
// the banners should only be added at the end of the build process
// ignore all comments during transpiling
shouldPrintComment: () => false
};
// Keep source files untransformed for local development
if (process.env.NODE_ENV === 'development') {
// In local development, we would prefer not to include any babel transforms as they make debugging more difficult
// However, there is an issue with testcafe which requires the optional chaining transform for SIW compatibility
// https://github.com/DevExpress/testcafe-hammerhead/issues/2714
babelOptions.plugins = babelOptions.plugins.concat([
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator'
]);
} else {
babelOptions.presets.unshift('@babel/preset-env'); // must run after preset-typescript
babelOptions.plugins = babelOptions.plugins.concat([
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-runtime'
]);
}
var babelExclude = /node_modules\/(?!p-cancelable)/;
module.exports = {
module: {
rules: [
{
test: /\.[jt]s$/,
exclude: babelExclude,
loader: 'babel-loader',
options: babelOptions
}
]
},
resolve: {
extensions: ['.js', '.ts'],
alias: {
'./node$': './browser', // use browser built-in objects and functions
}
},
plugins: [
new webpack.DefinePlugin({
SDK_VERSION: JSON.stringify(SDK_VERSION)
})
]
};