-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
69 lines (66 loc) · 1.89 KB
/
webpack.config.js
File metadata and controls
69 lines (66 loc) · 1.89 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
const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const ThreeMinifierPlugin = require("@yushijinhun/three-minifier-webpack");
const threeMinifier = new ThreeMinifierPlugin();
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const mode = process.env.NODE_ENV || 'development';
module.exports = {
mode: mode,
devtool: (mode === 'development') ? 'inline-source-map' : false,
performance: {
hints: false
},
entry: './src/main.ts',
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].[fullhash:8].js',
sourceMapFilename: '[name].[fullhash:8].map',
chunkFilename: '[id].[fullhash:8].js'
},
resolve: {
extensions: ['.ts', '.js'],
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
plugins: [
threeMinifier.resolver,
]
},
module: {
rules: [
{
test: /\.(ts|js)$/i,
exclude: /node_modules/,
use: ['ts-loader'],
},
{
test: /\.(gltf|bin|glb|obj)$/i,
use: [
{
loader: 'file-loader',
options: {
esModule: false,
},
},
],
}
],
},
plugins: [
new HtmlWebpackPlugin({ template: 'index.html' }),
new CopyPlugin({
patterns: [
{
from: path.join(__dirname, `src/assets/`),
to: path.join(__dirname, `build/assets/`)
},
],
}),
new CleanWebpackPlugin(),
threeMinifier,
],
optimization: {
splitChunks: {
chunks: 'all',
},
},
};