generated from monoflow-ayvu/monoflow-script-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
101 lines (96 loc) · 2.64 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
98
99
100
101
const path = require('path');
const fs = require('fs');
const CompressionPlugin = require("compression-webpack-plugin");
const BrotliPlugin = require('brotli-webpack-plugin');
const entryFile = path.resolve(__dirname, 'src/index.ts');
const distDir = path.resolve(__dirname, 'dist');
if (!fs.existsSync(entryFile)) {
console.error('entry file not found: ', entryFile);
process.exit(1);
}
if (!fs.existsSync(distDir)) {
fs.mkdirSync(distDir);
}
var babelOptions = {
presets: [
['@babel/env', {
targets: {
android: '4.4',
ie: 6,
},
bugfixes: true,
spec: true,
modules: false,
debug: false,
useBuiltIns: false,
}],
],
"plugins": [["@babel/plugin-transform-arrow-functions", { "spec": true }]]
};
module.exports = {
entry: entryFile,
target: 'es5',
// devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(t|j)s?$/,
use: [
{
loader: 'babel-loader',
options: babelOptions
},
{
loader: 'ts-loader',
options: {
allowTsInNodeModules: true
},
}
]
// exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: { "stream": false, "http": false, "url": false, "https": false, "zlib": false }
},
output: {
filename: 'bundle.js',
path: distDir,
chunkFormat: 'commonjs',
globalObject: 'this',
environment: {
// The environment supports arrow functions ('() => { ... }').
arrowFunction: false,
// The environment supports BigInt as literal (123n).
bigIntLiteral: false,
// The environment supports const and let for variable declarations.
const: false,
// The environment supports destructuring ('{ a, b } = obj').
destructuring: false,
// The environment supports an async import() function to import EcmaScript modules.
dynamicImport: false,
// The environment supports 'for of' iteration ('for (const x of array) { ... }').
forOf: false,
// The environment supports ECMAScript Module syntax to import ECMAScript modules (import ... from '...').
module: false,
// The environment supports optional chaining ('obj?.a' or 'obj?.()').
optionalChaining: false,
// The environment supports template literals.
templateLiteral: false,
},
},
optimization: {
usedExports: true,
},
plugins: [
new CompressionPlugin(),
new BrotliPlugin({
// asset: '[path].br',
// test: /\.(js|css|html|svg)$/,
// threshold: 10240,
// minRatio: 0.8
})
]
};