Skip to content

Commit 7ce4561

Browse files
authored
Merge pull request #187 from itsyoboieltr/fix/preprocessor-options
fix: preprocessor options for the default preprocessor
2 parents 21ead14 + 3bf642a commit 7ce4561

File tree

10 files changed

+95
-3
lines changed

10 files changed

+95
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.22.0 (2025-11-27)
4+
5+
- fix: preprocessor options for the default preprocessor
6+
37
## 4.22.0-alpha.0 (2025-07-31)
48

59
- feat(experimental): add support for markdown in nunjucks preprocessor

src/Plugin/PluginService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class PluginService {
4848
// add reference for the preprocessor option into the loader options
4949
if (pluginOptions.preprocessor != null && loaderOptions.preprocessor == null) {
5050
loaderOptions.preprocessor = pluginOptions.preprocessor;
51+
}
5152

52-
if (pluginOptions.preprocessorOptions && !loaderOptions.preprocessorOptions) {
53-
loaderOptions.preprocessorOptions = pluginOptions.preprocessorOptions;
54-
}
53+
if (pluginOptions.preprocessorOptions && !loaderOptions.preprocessorOptions) {
54+
loaderOptions.preprocessorOptions = pluginOptions.preprocessorOptions;
5555
}
5656

5757
context = {
1.74 KB
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Home</title>
5+
</head>
6+
<body>
7+
<!-- path to partials directory -->
8+
<div>header</div>
9+
<nav>Navigation</nav>
10+
<h1>Breaking Bad</h1>
11+
<ul class="people">
12+
<li>Walter White</li>
13+
<li>Jesse Pinkman</li>
14+
</ul>
15+
<img src="assets/img/apple.02a7c382.png" alt="apple" />
16+
<!-- path to partials directory -->
17+
<div>footer</div>
18+
</body>
19+
</html>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title><%= it.title %></title>
5+
</head>
6+
<body>
7+
<!-- path to partials directory -->
8+
<%~ include('src/views/partials/header.html') %>
9+
<%~ include('src/views/pages/includes/nav.html') %>
10+
<h1><%= it.headline %></h1>
11+
<ul class="people">
12+
<% for (let i = 0; i < it.people.length; i++) {%>
13+
<li><%= it.people[i] %></li>
14+
<% } %>
15+
</ul>
16+
<img src="@images/apple.png" alt="apple" />
17+
<!-- path to partials directory -->
18+
<%~ include('src/views/partials/footer.html') %>
19+
</body>
20+
</html>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<nav>Navigation</nav>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>footer</div>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div>header</div>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const path = require('path');
2+
const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'production',
6+
7+
output: {
8+
path: path.join(__dirname, 'dist/'),
9+
},
10+
11+
resolve: {
12+
alias: {
13+
'@images': path.join(__dirname, '../../../fixtures/images'),
14+
},
15+
},
16+
17+
plugins: [
18+
new HtmlBundlerPlugin({
19+
entry: {
20+
index: {
21+
import: './src/views/pages/home.html',
22+
data: {
23+
title: 'Home',
24+
headline: 'Breaking Bad',
25+
people: ['Walter White', 'Jesse Pinkman'],
26+
},
27+
},
28+
},
29+
// test default preprocessor (eta) and preprocessorOptions
30+
preprocessorOptions: { useWith: false },
31+
}),
32+
],
33+
34+
module: {
35+
rules: [
36+
{
37+
test: /\.(png|svg|jpe?g|webp)$/i,
38+
type: 'asset/resource',
39+
generator: {
40+
filename: 'assets/img/[name].[hash:8][ext]',
41+
},
42+
},
43+
],
44+
},
45+
};

test/preprocessor.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ beforeAll(() => {
88

99
describe('Eta', () => {
1010
test('default', () => compareFiles('_preprocessor/eta-default'));
11+
test('default with options', () => compareFiles('_preprocessor/eta-default-with-options'));
1112
test('option views', () => compareFiles('_preprocessor/eta-option-views'));
1213
test('option async', () => compareFiles('_preprocessor/eta-option-async'));
1314
test('include md', () => compareFiles('_preprocessor/eta-include-md'));

0 commit comments

Comments
 (0)