-
Notifications
You must be signed in to change notification settings - Fork 265
/
webpack.config.js
72 lines (70 loc) · 1.72 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
// import CopyWebpackPlugin from 'copy-webpack-plugin';
import { createRequire } from 'module';
import { dirname, resolve } from 'path';
import path from 'path';
import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';
import { fileURLToPath } from 'url';
import webpack from 'webpack';
const require = createRequire(import.meta.url);
export default {
target: 'web',
mode: 'production',
devtool: false,
entry: {
main: './src/index.ts',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.dest.json',
},
},
],
},
],
},
output: {
path: resolve(dirname(fileURLToPath(import.meta.url)), './dest'),
filename: 'main.js',
library: {
type: 'module',
},
chunkFormat: 'module',
},
experiments: {
outputModule: true,
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
],
resolve: {
plugins: [new ResolveTypeScriptPlugin()],
alias: {
// All node specific code, wherever it's located, should be imported as below.
// Provides a clean and simple way to always strip out the node code for the web build.
'./node/index.js': false,
},
fallback: {
crypto: false,
os: false,
fs: false,
path: false,
url: false,
worker_threads: false,
buffer: require.resolve('buffer/'),
util: require.resolve('util/'),
stream: require.resolve('stream-browserify'),
tty: require.resolve('tty-browserify'),
},
},
};