-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Merge site.copy and site.loadAssets? #571
Labels
Comments
Hi, I certainly think it would be good to simplify this! It took me a while to figure out why things weren't working when I was trying to get a js file loaded while exploring #580. using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an idea that would like to discuss and hear the opinion of more people. If it's approved, it's a huge breaking change so it would be implemented in Lume 3 (that I don't have plans to work on that anytime soon).
Currently, Lume has several ways to output files to the site:
.html
or/index.html
(depending on the prettyUrls configuration). For example/dir/page.md
generates/dir/page/index.html
./dir/file.css
generates/dir/file.css
.site.copy()
.The problem is assets and static files serves a similar purpose: output non-html files. But due static files are copies as is, they are not processed, so plugins like postcss, transform_images, sass, svgo, etc don't work with these files.
Let's see the following example:
In this configuration, the build copy all CSS files and you may expect these files to be transformed with the
postcss
plugin. However the plugin only works with assets. I think this behavior may be confusing.Static files exist to avoid loading in memory files for no reason. Only files that must be transformed (compiled, minified, etc) should be loaded in memory. It's a copy of the Passthrought File Copy feature of Eleventy.
But I think Lume should be more clever than this, instead of delegating to the user the decision of configuring a file to be loaded or copied, depending on the selected plugins. My idea is to merge
site.copy()
andsite.loadAssets()
. This will remove duplicated code and simplify the internal implementation. This new feature could have the generical name of Files.Files are not loaded initially (like static files) but will be on demand. If a file is being processed, the content will be loaded automatically. For example:
How to rename files?
Due to files are not loaded initially, we cannot include data like a frontmatter with the
url
value to change the output path. We can use_data
files to define aurl
function or change thebasename
of the folder.We can also use preprocessors to assign data to the files without loading it (file content would be loaded only for processors, not preprocessors). For example:
Static files allow to rename of the file in the
copy
function. For examplesite.copy("assets", "")
. We can implement the same feature on files.Thoughts?
The text was updated successfully, but these errors were encountered: