-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
75 lines (74 loc) · 2.08 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
const path = require('path');
const webpack = require('webpack');
const pkg = require('./package.json');
module.exports = (env) => {
const mode = env.production ? 'production' : 'development';
return {
entry: env.production ? './src/index.ts' : './src/dev.ts',
mode,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
fallback: {
"fs": false,
"tls": false,
"net": false,
"path": false,
"zlib": false,
"http": false,
"https": false,
"stream": false,
"crypto": false,
'path': require.resolve('path-browserify'), // only the posix part
}
},
output: {
filename: 'react-browser-loader.js',
path: path.resolve(__dirname, './dist'),
library: {
type: 'umd',
name: `react-browser-loader`,
},
},
plugins: [
new webpack.ProvidePlugin({
process: 'process/browser',
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(mode), // see also: https://webpack.js.org/configuration/optimization/#optimizationnodeenv
'process.env.NODE_DEBUG': 'undefined',
'process.env.DEBUG': 'undefined',
'process.env.BABEL_ENV': JSON.stringify(mode),
'process.env.BABEL_TYPES_8_BREAKING': false,
// further optimizations (ease dead code elimination)
'process.stdin': 'null',
'process.stdout': 'null',
'process.stderr': 'null',
'process.browser': 'true',
'process.env.TERM': 'undefined',
// config
'process.env.GEN_SOURCEMAP': JSON.stringify(false),
'process.env.VERSION': JSON.stringify(pkg.version),
}),
new webpack.ProvidePlugin({
'Buffer': ['buffer', 'Buffer'],
'process': 'process',
}),
],
devServer: {
static: {
directory: path.join(__dirname, '/'),
},
compress: true,
port: 7777,
}
};
}