forked from MatthewHerbst/react-to-print
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.prod.config.js
80 lines (76 loc) · 1.91 KB
/
webpack.prod.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
'use strict';
const path = require('path');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const basicConfig = {
mode: 'production',
entry: './src/index.ts',
output: {
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,
},
path: path.resolve(__dirname, './lib'),
globalObject: `(typeof self !== 'undefined' ? self : this)`,
},
optimization: {
minimize: true,
},
externals: {
'react': 'react',
'react-dom': 'react-dom',
},
module: {
rules: [
{
test: /\.ts(x?)$/,
include: path.resolve(__dirname, 'src'),
loader: 'ts-loader',
}
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
};
module.exports = [
{
...basicConfig,
output: {
...basicConfig.output,
filename: 'index.js',
library: 'lib',
umdNamedDefine: true,
libraryTarget: 'umd',
},
plugins: [
new CleanWebpackPlugin(),
],
},
{
...basicConfig,
output: {
...basicConfig.output,
environment: {
...basicConfig.output.environment,
module: true,
},
filename: 'index.mjs',
libraryTarget: 'module',
},
experiments: {
outputModule: true
},
},
];