-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
75 lines (72 loc) · 2.1 KB
/
webpack.config.js
File metadata and controls
75 lines (72 loc) · 2.1 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
/* globals require, module, __dirname */
const path = require('path');
const glob = require('glob');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require("copy-webpack-plugin");
const files = glob.sync('./[1-9]-*/*.html').map(pth => pth.replace('.html', '')).concat(
glob.sync('./1[0-9]-*/*.html').map(pth => pth.replace('.html', ''))
);
const config = {
mode: 'development',
entry: files.reduce((acc, file) => {
acc[file] = file + ".js";
return acc;
}, {}),
module: {
rules: [
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
},
{
test: /\.(stl|gltf|glb|bin|obj|mtl)$/i,
type: 'asset/resource',
},
{
test: /\.json$/,
type: 'asset/resource',
},
]
},
plugins: [
// Copy files from source to destination for examples from before using webpack
new CopyWebpackPlugin({
patterns: [
{ from: "favicon.*", to: "." },
{ from: "index.html", to: "." },
{ from: "./0-Day-1/*.js", to: "." },
{ from: "./0-Day-1/*.html", to: "." },
{ from: "./1-JS-Basics/*.css", to: "." },
],
}),
...files.map(file => new HtmlWebpackPlugin({template: `./${file}.html`, filename: `./${file}.html`, chunks: [file]})),
],
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
clean: true,
},
devServer: {
port: 8080,
hot: true,
static: [
{
directory: path.join(__dirname, 'assets'),
publicPath: '/assets'
}
]
},
resolve: {
extensions: ['.js'],
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
}
};
module.exports = config;