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 00000000..c3b5ce07 Binary files /dev/null and b/test/cases/_preprocessor/eta-default-with-options/expected/assets/img/apple.02a7c382.png differ 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

+ + 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 %>

+ + 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'));