forked from RyugaRyuzaki/three.model.bim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
107 lines (106 loc) · 2.1 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
const path = require("path");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
mode: "development",
entry: {
bundle: path.resolve(__dirname, "src/index.js"),
// bundle: path.resolve(__dirname, "src/index.test.js"),
},
output: {
path: path.resolve(__dirname, "build/"),
filename: "[name].js",
clean: true,
assetModuleFilename: "[name][ext]",
publicPath: "./",
},
devtool: "source-map",
devServer: {
static: {
directory: path.resolve(__dirname, "build"),
},
port: 4001,
open: true,
hot: true,
compress: true,
historyApiFallback: true,
// watchFiles: true,
},
module: {
exprContextCritical: false,
rules: [
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: "asset/resource",
generator: {
filename: "assets/[name][ext]",
},
},
{
test: /\.wasm$/,
type: "asset/resource",
generator: {
filename: "wasm/[name][ext]",
},
},
{
test: /\.json$/,
type: "asset/resource",
generator: {
filename: "json/[name][ext]",
},
},
{
test: /\.js$/, // Sẽ sử dụng babel-loader cho những file .js
exclude: /node_modules/, // Loại trừ thư mục node_modules
use: {
loader: "babel-loader",
},
},
{
test: /\.(glb|gltf)$/,
use: [
{
loader: "file-loader",
},
],
},
],
},
plugins: [
new Dotenv(),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, "src/index.html"),
title: "React openBIM",
filename: "index.html",
inject: true,
}),
new CopyWebpackPlugin({
patterns: [
{
from: "src/assets/wasm",
to: "wasm", // copies all files to dist/assets
},
],
}),
],
resolve: {
enforceExtension: false,
extensions: [".js", ".json", ".wasm"],
},
optimization: {
splitChunks: {
chunks: "all",
},
},
};