-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
119 lines (117 loc) · 2.88 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import CopyWebpackPlugin from 'copy-webpack-plugin';
import { createRequire } from 'module';
import { dirname, resolve } from 'path';
import ResolveTypeScriptPlugin from 'resolve-typescript-plugin';
import { fileURLToPath } from 'url';
import webpack from 'webpack';
const require = createRequire(import.meta.url);
export default (_, argv) => ({
target: 'web',
mode: 'production',
devtool: 'source-map',
entry: {
main: './src/app/index.tsx',
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.dest.json',
},
},
],
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.module\.scss$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[local]_[hash:base64:5]',
},
},
},
'sass-loader',
],
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/,
type: 'asset/resource',
},
{
test: /\.scss$/,
exclude: /\.module\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
output: {
path: resolve(dirname(fileURLToPath(import.meta.url)), './dest'),
filename: 'index.js',
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(argv.mode || 'production'),
},
}),
new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }),
new CopyWebpackPlugin({
patterns: [
{
from: `${dirname(require.resolve(`@aztec/circuits.js`)).replace(
/\/dest$/,
'',
)}/resources/aztec3-circuits.wasm`,
to: 'aztec3-circuits.wasm',
},
{
from: './src/assets',
},
{
from: './src/app/index.html',
to: 'index.html',
},
],
}),
],
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,
events: require.resolve('events/'),
buffer: require.resolve('buffer/'),
util: require.resolve('util/'),
stream: require.resolve('stream-browserify'),
string_decoder: require.resolve('string_decoder/'),
tty: require.resolve('tty-browserify'),
},
},
devServer: {
port: 5173,
historyApiFallback: true,
client: {
overlay: false,
},
},
});