From 3bf642ac81b130573bc1e9522c1f925519218597 Mon Sep 17 00:00:00 2001 From: Norbert Elter <72046715+itsyoboieltr@users.noreply.github.com> Date: Thu, 27 Nov 2025 21:01:57 +0400 Subject: [PATCH] fix: preprocessor options for the default preprocessor --- CHANGELOG.md | 4 ++ src/Plugin/PluginService.js | 6 +-- .../expected/assets/img/apple.02a7c382.png | Bin 0 -> 1779 bytes .../expected/index.html | 19 ++++++++ .../src/views/pages/home.html | 20 ++++++++ .../src/views/pages/includes/nav.html | 1 + .../src/views/partials/footer.html | 1 + .../src/views/partials/header.html | 1 + .../webpack.config.js | 45 ++++++++++++++++++ test/preprocessor.test.js | 1 + 10 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 test/cases/_preprocessor/eta-default-with-options/expected/assets/img/apple.02a7c382.png create mode 100644 test/cases/_preprocessor/eta-default-with-options/expected/index.html create mode 100644 test/cases/_preprocessor/eta-default-with-options/src/views/pages/home.html create mode 100644 test/cases/_preprocessor/eta-default-with-options/src/views/pages/includes/nav.html create mode 100644 test/cases/_preprocessor/eta-default-with-options/src/views/partials/footer.html create mode 100644 test/cases/_preprocessor/eta-default-with-options/src/views/partials/header.html create mode 100644 test/cases/_preprocessor/eta-default-with-options/webpack.config.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dfb2c3f..67ef0216 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 4.22.0 (2025-11-27) + +- fix: preprocessor options for the default preprocessor + ## 4.22.0-alpha.0 (2025-07-31) - feat(experimental): add support for markdown in nunjucks preprocessor diff --git a/src/Plugin/PluginService.js b/src/Plugin/PluginService.js index b4c43495..01771bba 100644 --- a/src/Plugin/PluginService.js +++ b/src/Plugin/PluginService.js @@ -48,10 +48,10 @@ class PluginService { // add reference for the preprocessor option into the loader options if (pluginOptions.preprocessor != null && loaderOptions.preprocessor == null) { loaderOptions.preprocessor = pluginOptions.preprocessor; + } - if (pluginOptions.preprocessorOptions && !loaderOptions.preprocessorOptions) { - loaderOptions.preprocessorOptions = pluginOptions.preprocessorOptions; - } + if (pluginOptions.preprocessorOptions && !loaderOptions.preprocessorOptions) { + loaderOptions.preprocessorOptions = pluginOptions.preprocessorOptions; } context = { diff --git a/test/cases/_preprocessor/eta-default-with-options/expected/assets/img/apple.02a7c382.png b/test/cases/_preprocessor/eta-default-with-options/expected/assets/img/apple.02a7c382.png new file mode 100644 index 0000000000000000000000000000000000000000..c3b5ce07f66020372ad9fffeff0bdb9111cf21cf GIT binary patch literal 1779 zcmV004pr0{{R3_H{EN0001KP)t-s*4Eb7 z*Vpv)^!4@i_xJbO+S=yk=JxjX^78W4)z$3m?BL+w+9>~<>ln$WQr zd70F6ds2)6;~=3cz?Gthpc%ww1cTgMkI!%%pAq5?K+9i~j}e+11Ra1V4Ohiu)~5|0 z)&LQ?tjSmCYIOicWr9~|#Ew(ml8C!4FdW15`*G z5LrPGSnt%NANl2lj=N2PdFNoc*dJ-S4?2O0?UJ^`Fz_4|pcBSZx8#w4Zrd!%Q!N81giFl=h+ifFP0`&zK!G@*?zjk6lYpiM54!R5 zujv6XoZ8nx>T{cRJ`C|7zmALGzI`J9*FSJ5ycba#$@0X27`yE&A%6d$f%^|q>Nqro zULTGF?1*5}%O|WCQ{GF`xYvi{Jh|JL(p8k{ddwn>vCyCp8lAa7p|5b$DJ{$*#$weK&Fz(}f`mZAF^x@di zOcW|}>~%c_oBosP^x^37pt3hU-#hr;{8z=W!-tcOsA*3}-1J{X*zUvea}x5l@PCea z_}=_i5w`kJW7-)UYE9X^?mK$9Hvc_?-{wP|d9k(ksEneyy^*d7Q=9*)7`FIOZ|MW= zvixY<=W7!6E!(vDuOd|YPzO+C1X+X-InGC|NpAOFMHr#UBREWb{*$5^!noO376I(> z-!q2c?L7mFtPl42PXZcY_C~l&iu?RmW%<_h;oN{j{U^m@h-yBZ9dMxkD#Em$<=Im_ z(0@{IKAaNJQf#Aq;J*UI5p8+;6f+R(;GM*}NOkQq|4G$+I2j=03(d=^e(gj5JqcfY zI2oXo@NvU+_u8R;=s&5N52pgO4kib5wx{aDf9k&{AoF1+eK-Z6@Sofpzmz^4=|3s^ zRKK|%px~1q|H5O4NBgf7ofNR}pClAM#3TJT3n2GjwV`7e+=nd7qx?5HV9kG0+=nQ# z4Gle)lC=R}{U^nI2zq=I0@nOj5gzpTrUPvHPfGVN+9ZHV|Bcbzoe5CozcB(b6QI(6 zUj*3Zzpnrs?!V)0ANyxsG513|aU-!T_F9&J+sw`K$pDA?FJr&YI_H=b_mGGa(amxR z$ZE0+xtGzn}M1$5!$|3!#df6Jh($0lcHqeiVj95-%Y|BVG=W^1Y|v&%DE( zL3w;Hl<*L}mdl#Ml&Y-K z4{&9`j#D2UN^VqHRs&+t02~*=PZa6_vaW7sX#rw5CH~Ah1TY>D_^#pH0zJUx^aIq@ zCxE6MOn=h6Pv0Lw`U&7;SvaoU5WsVp;xL=>#SyjS`b8(8b(Qm@FyAb!yzEq+Vmzw` zcu%1f5WBRhzBpg0#>vUX`^EV>bjHgIHGaqIy8wHgJ()>#ZX7*r0HSQw zSG0?>XYGIpgO!CV#?Y}-tNSHKwbR+b@lat{{T)J Vs6AcRANBwM002ovPDHLkV1iIdiy8m` literal 0 HcmV?d00001 diff --git a/test/cases/_preprocessor/eta-default-with-options/expected/index.html b/test/cases/_preprocessor/eta-default-with-options/expected/index.html new file mode 100644 index 00000000..9088f32f --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/expected/index.html @@ -0,0 +1,19 @@ + + + + Home + + + +
header
+ +

Breaking Bad

+
    +
  • Walter White
  • +
  • Jesse Pinkman
  • +
+ apple + +
footer
+ + \ No newline at end of file diff --git a/test/cases/_preprocessor/eta-default-with-options/src/views/pages/home.html b/test/cases/_preprocessor/eta-default-with-options/src/views/pages/home.html new file mode 100644 index 00000000..e5f22f08 --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/src/views/pages/home.html @@ -0,0 +1,20 @@ + + + + <%= it.title %> + + + + <%~ include('src/views/partials/header.html') %> + <%~ include('src/views/pages/includes/nav.html') %> +

<%= it.headline %>

+
    + <% for (let i = 0; i < it.people.length; i++) {%> +
  • <%= it.people[i] %>
  • + <% } %> +
+ apple + + <%~ include('src/views/partials/footer.html') %> + + \ No newline at end of file diff --git a/test/cases/_preprocessor/eta-default-with-options/src/views/pages/includes/nav.html b/test/cases/_preprocessor/eta-default-with-options/src/views/pages/includes/nav.html new file mode 100644 index 00000000..948b55b6 --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/src/views/pages/includes/nav.html @@ -0,0 +1 @@ + diff --git a/test/cases/_preprocessor/eta-default-with-options/src/views/partials/footer.html b/test/cases/_preprocessor/eta-default-with-options/src/views/partials/footer.html new file mode 100644 index 00000000..27dee2fa --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/src/views/partials/footer.html @@ -0,0 +1 @@ +
footer
diff --git a/test/cases/_preprocessor/eta-default-with-options/src/views/partials/header.html b/test/cases/_preprocessor/eta-default-with-options/src/views/partials/header.html new file mode 100644 index 00000000..51bece6a --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/src/views/partials/header.html @@ -0,0 +1 @@ +
header
diff --git a/test/cases/_preprocessor/eta-default-with-options/webpack.config.js b/test/cases/_preprocessor/eta-default-with-options/webpack.config.js new file mode 100644 index 00000000..5a855eed --- /dev/null +++ b/test/cases/_preprocessor/eta-default-with-options/webpack.config.js @@ -0,0 +1,45 @@ +const path = require('path'); +const HtmlBundlerPlugin = require('@test/html-bundler-webpack-plugin'); + +module.exports = { + mode: 'production', + + output: { + path: path.join(__dirname, 'dist/'), + }, + + resolve: { + alias: { + '@images': path.join(__dirname, '../../../fixtures/images'), + }, + }, + + plugins: [ + new HtmlBundlerPlugin({ + entry: { + index: { + import: './src/views/pages/home.html', + data: { + title: 'Home', + headline: 'Breaking Bad', + people: ['Walter White', 'Jesse Pinkman'], + }, + }, + }, + // test default preprocessor (eta) and preprocessorOptions + preprocessorOptions: { useWith: false }, + }), + ], + + module: { + rules: [ + { + test: /\.(png|svg|jpe?g|webp)$/i, + type: 'asset/resource', + generator: { + filename: 'assets/img/[name].[hash:8][ext]', + }, + }, + ], + }, +}; diff --git a/test/preprocessor.test.js b/test/preprocessor.test.js index 8bc256d3..8664c5a0 100644 --- a/test/preprocessor.test.js +++ b/test/preprocessor.test.js @@ -8,6 +8,7 @@ beforeAll(() => { describe('Eta', () => { test('default', () => compareFiles('_preprocessor/eta-default')); + test('default with options', () => compareFiles('_preprocessor/eta-default-with-options')); test('option views', () => compareFiles('_preprocessor/eta-option-views')); test('option async', () => compareFiles('_preprocessor/eta-option-async')); test('include md', () => compareFiles('_preprocessor/eta-include-md'));