-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
51 lines (48 loc) · 1.29 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
// Webpack Config File, compiles src/index.ts into dist/bundle.js
const path = require('path');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const { webpack, DefinePlugin } = require("webpack");
// Include dotenv file in webpack bundle
const dotenv = require("dotenv");
dotenv.config();
module.exports = {
entry: "./src/index.ts",
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
// Ignore some packages when bundling code (from https://stackoverflow.com/q/64557638/20791863)
fallback: {
fs: false,
tls: false,
net: false,
path: false,
zlib: false,
http: false,
https: false,
stream: false,
crypto: false,
async_hooks: false,
"crypto-browserify": require.resolve("crypto-browserify"), //if you want to use this module also don't forget npm i crypto-browserify
},
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
plugins: [
new NodePolyfillPlugin(),
new DefinePlugin({
"process.env":
JSON.stringify(dotenv.config().parsed) ?? assert.fail("Bad .env file"),
}),
],
};