-
-
Notifications
You must be signed in to change notification settings - Fork 498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addTransform with minifyCSS option enabled removes inline styles generated by eleventy-bundle-pluging #3195
Comments
I've reproduced this issue on stackblitz. Do This is because |
Transform order is important! Unfortunately plugins complicate this as plugins are run in a second stage of config (and as such will be executed after any application defined transforms). Here’s a small test case: module.exports = function(eleventyConfig) {
eleventyConfig.addTransform("top.before", async function(content) {
console.log( "top.before" );
return content;
});
eleventyConfig.addPlugin(eleventyConfig => {
eleventyConfig.addTransform("plugin", async function(content) {
console.log( "plugin" );
return content;
});
})
eleventyConfig.addTransform("top.after", async function(content) {
console.log( "top.after" );
return content;
});
}; This logs:
You have a couple of options here. Option 1You can use the new 3.0+ feature to execute a plugin immediately (not in a second stage). For this plugin I believe it’s okay but it may cause complications for other plugins (if you’re using a return object in your configuration callback). Using the separate export approach in #3246 fixes this (3.0.0-alpha.6+). const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(bundlerPlugin, { immediate: true });
}; Option 2Your other option (which is Eleventy 2.0 friendly) is to modify the CSS output from the bundle directly. There is an example of that here: |
|
Operating system
macOS Sonoma Version 14.2.1
Eleventy
2.0.1
Describe the bug
if I add the option
minifyCSS: true
we will not have inline styles fromeleventy-plugin-bundle
plugin, I guess because this happens before css bundle is ready?Because if I add manually the following, the html-minifier doesn't remove it from output
If I remove
minifyCSS: true
option it would minifiy html only.Will be great to have an option to minify the output completely, including inline css, at release remove the new lines and whitespaces.
Reproduction steps
npm run build
4.Check the output html file, the inline css from bundle plugin is missing.
Expected behavior
To minify the inline css too using the transforms and minifyCSS option enabled
Reproduction URL
No response
Screenshots
As we can see from the screenshot the manual added code is minified
but the bundled css from eleventy-bundle-plugin is missing, just empty
<style>
tagsThe text was updated successfully, but these errors were encountered: