-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
119 lines (118 loc) · 2.9 KB
/
Copy pathwebpack.config.js
File metadata and controls
119 lines (118 loc) · 2.9 KB
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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require("webpack");
const dotenv = require("dotenv");
dotenv.config();
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
publicPath: 'auto',
webassemblyModuleFilename: 'wasm/[hash].wasm',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules|public\/wasm/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.wasm$/,
type: 'webassembly/async',
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
templateParameters: {
process: {
env: {
NODE_ENV: process.env.NODE_ENV
}
}
}
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
React: 'react',
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'public',
to: '',
globOptions: {
ignore: ['**/index.html'],
},
},
],
}),
new webpack.DefinePlugin({
"process.env.REGISTRY_URL": JSON.stringify(process.env.REGISTRY_URL),
"process.env.REPO_OWNER": JSON.stringify(process.env.REPO_OWNER),
"process.env.REGISTRY_USERNAME": JSON.stringify(process.env.REGISTRY_USERNAME),
"process.env.REGISTRY_PASSWORD": JSON.stringify(process.env.REGISTRY_PASSWORD),
}),
],
resolve: {
fallback: {
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
buffer: require.resolve('buffer/'),
path: require.resolve('path-browserify'),
fs: false,
vm: require.resolve('vm-browserify'),
},
alias: {
wasm: path.resolve(__dirname, 'public/wasm'),
},
extensions: ['.js', '.jsx', '.wasm'], // Ensure .wasm files are resolved
},
experiments: {
asyncWebAssembly: true,
topLevelAwait: true,
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
compress: true,
host: '0.0.0.0', // Added this line to specify the host
port: 8082, // Changed the port to 8082
historyApiFallback: true,
open: true,
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
performance: {
maxAssetSize: 5000000, // 5 MB
maxEntrypointSize: 5000000, // 5 MB
},
};