-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
78 lines (67 loc) · 1.89 KB
/
webpack.config.js
File metadata and controls
78 lines (67 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
70
71
72
73
74
75
76
77
78
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
// Build mode: enables optimizations like minification
mode: "production",
// Controls how much information Webpack prints to the console
stats: {
errorDetails: true, // include full error stack/details
},
entry: {
main: "./js/main.js",
layoutGenerator: "./js/layout-generator/main.js",
},
output: {
path: path.resolve(__dirname, "public/assets"),
filename: "js/[name].js",
assetModuleFilename: "[path][name][ext]",
},
module: {
rules: [
{
test: /\.css$/i,
use: [
// Extract CSS into separate files instead of injecting into JS
MiniCssExtractPlugin.loader,
{
// Resolves @import and url() in CSS
loader: "css-loader",
options: {
// Disable url() handling so Webpack does NOT process images (Eleventy is handling images instead)
url: false,
},
},
],
},
{
test: /\.scss$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
url: false,
},
},
// Compiles SCSS → CSS
"sass-loader",
],
},
{
test: /\.(png|jpg|jpeg|gif|svg)$/i,
type: "asset/resource",
// Prevent Webpack from processing images in this folder because Eleventy already copies them
exclude: path.resolve(__dirname, "assets/img"),
},
],
},
plugins: [
new MiniCssExtractPlugin({
// Output filename for extracted CSS
// [name] corresponds to entry names (main, layoutGenerator)
filename: "[name].css",
}),
],
// Generate source maps for debugging (maps compiled code back to source)
devtool: "source-map",
};