-
-
Notifications
You must be signed in to change notification settings - Fork 493
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
Easier way to run transforms on passthrough copy files #344
Comments
Exactly. passthroughFileCopy: true does copy files with non-matching template file extensions directly to your output directory without modification. So, you can consider processing your js files with external tool like grunt, gulp, webpack, etc, or inlining your js through the addFilter API; especially if you had a small js file and you want to reduce the number of http requests |
Correct! Upvote #117 which will allow you to do this much easier! |
Upvoted. At the moment, I'd prefer to avoid adding any other dependencies like webpack, etc. |
This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open. View the enhancement backlog here. Don’t forget to upvote the top comment with 👍! |
I'm facing a similar problem (but with CSS). I also do not want to add additional dependencies like gulp, grunt, webpack, etc. For now I'm using a "real" template file ( It would be nice if files added via The only reason for the // stylesheet.njk
---
permalink: /stylesheet.css
---
{% include "css/main.css" %} // _includes/css/main.css
body { font-family: 'Comic Sans MS' }
a { color: salmon } // .eleventy.js
// ...
config.addTransform('doTheCSSWork', (content, outputPath) => {
if (outputPath.endsWith('.css')) {
return processTheCSS()
}
return content
}) |
Nice hack! |
OK, but I feel like transforms should work on
Considering these two points, I just don't see any advantage to the current behavior. #117 would fix this, to be sure. If #117 were able to extend existing renderers instead of overwriting them, I guess transforms would be obsoleted anyway. |
Is there an active issue to track this feature? I need this too and agree that simply minifying external css/js files shouldn't be this difficult vs working with inline css/js. |
As #1686 was merged, this will unlock passing a Shipping with 2.0.0-canary.12 |
I'm trying to add a transform to minify my "*.js" file. ".js" is listed in the templateFormats, and passThroughFileCopy is true. I've modified the example in Add Filter to create the transform.
eleventyConfig.addTransform("jsmin", function(content, outputPath) {
if( outputPath.endsWith(".js") ) {
let minified = uglifyjs.minify(content);
if ( minified.error ) {
console.log("Uglify JS error: ", minified.error);
}
return minified.code;
}
return content;
});
However, nothing seems to be happening. It looks like transforms are only applied to files that actually have some template processing.
How can I minify my js files?
The text was updated successfully, but these errors were encountered: