-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwebpack.config.js
executable file
·97 lines (92 loc) · 2.63 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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* eslint-disable */
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const babelExclude = /node_modules/;
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
// .BundleAnalyzerPlugin;
const CompressionPlugin = require('compression-webpack-plugin');
const alias = {
"@core-types": path.resolve(__dirname, './src/types/'),
"@utils": path.resolve(__dirname, './src/helpers/utils/'),
"@config": path.resolve(__dirname, './src/config/'),
"@helpers": path.resolve(__dirname, './src/helpers/'),
"@universal-schema": path.resolve(__dirname, 'src/universal-schema/'),
"@cross-framework-wrapper": path.resolve(__dirname, 'src/cross-framework-wrapper/'),
"@generated": path.resolve(__dirname, 'src/framework/generated/'),
"@framework": path.resolve(__dirname, 'src/framework/'),
};
if (process.env.NODE_ENV !== 'production' && process.env.NO_STUBS === undefined) {
};
const babelLoader = {
test: /\.(ts|js|jsx|tsx)$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
compact: true,
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
browsers: ['last 2 versions', 'ie >= 9'],
},
},
],
'@babel/typescript',
'@babel/preset-react',
],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-syntax-dynamic-import',
],
env: {
test: {
plugins: [
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-syntax-dynamic-import',
],
},
},
},
};
var config = {
entry: path.join(__dirname, 'src/index.ts'),
mode: 'production',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
libraryTarget: 'commonjs',
},
module: {
rules: [
{
oneOf: [babelLoader],
},
],
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
alias,
},
externals: /^(react|@material-ui(\/.*)?|immutability-helper|classnames|lodash(\/.*)?|@material-ui\/icons(\/.*)?|nanoid)$/,
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
// new BundleAnalyzerPlugin()
new CompressionPlugin(),
],
target: 'node',
optimization: {
minimize: true,
},
};
module.exports = config