forked from costflow/parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
68 lines (64 loc) · 2.16 KB
/
webpack.config.js
File metadata and controls
68 lines (64 loc) · 2.16 KB
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
/* eslint-env node */
/* eslint-disable @typescript-eslint/no-var-requires */
const { join } = require('path')
const webpack = require('webpack')
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const DIR_SRC = join(__dirname, 'src')
const DIR_DIST = join(__dirname, 'dist')
const IS_PRODUCTION = process.argv.some((arg) => arg === 'production' || arg === '--production')
module.exports = {
mode: IS_PRODUCTION ? 'production' : 'development',
target: 'web',
entry: {
main: [
'core-js/stable',
'regenerator-runtime/runtime',
join(DIR_SRC, 'index'),
],
},
output: {
path: DIR_DIST,
publicPath: '/',
filename: 'index.min.js',
libraryTarget: 'umd',
},
devtool: IS_PRODUCTION ? false : 'inline-source-map',
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
cacheDirectory: true,
babelrc: false,
presets: [
["@babel/preset-env"], // Defaults to ES5.
["@babel/preset-typescript", {allowNamespaces: true}]
],
plugins: [
["@babel/plugin-proposal-class-properties", { loose: true }],
["@babel/plugin-proposal-optional-chaining"],
["@babel/plugin-proposal-nullish-coalescing-operator"],
]
}
}
},
]
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
...(process.env.ANALYZE ? [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: true,
// reportFilename: path.join(__dirname, 'bundle-report.html'),
}),
] : []),
],
}