Open bcardarella opened 5 years ago
Yes, or maybe. Since I'm not a user of sass or other CSS preprocessor, I cannot give you a clear answer.
There should be many ways to implement the sass plugin, but the only idea I can come up with right now is to put the main functionality in build_succeeded/2
callback.
Once Serum has successfully built the project, the build_succeeded/2
callback will be called for all enabled plugins, with the source directory and the output directory as arguments.
At that moment, assets are already copied to /path/to/output/assets
directory. And that directory may contain any unprocessed sass files.
The plugin should find all sass files using an appropriate function (e.g. Path.wildcard/1
) and run the external program using System.cmd/3
to replace all sass sources into CSS files.
Several things to consider:
The plugin probably use an external command to run the sass compiler. (There is a package on Hex, but I'm not willing to use that...) Therefore the plugin should be implemented to work on any major platform.
The sass processor may bundle the output into one CSS file (does it?). Plugin users should be directed to add appropriate <link rel="stylesheet" ...>
tags referencing valid CSS assets.
The plugin won't work with Serum themes, as plugins are not aware of themes at all... yet.
I would advocate for a hook specifically to accommodate sass and other transpilers. Considering how close Serum is to Jekyll if sass was supported one could import Jekyll templates very easily which would make Serum a very attractive static site generator
I currently don't have any plans to make Serum Jekyll-compatible, or attractive to those who have used Jekyll. And I don't want people to regard Serum as "an Elixir implementation of Jekyll" or something else like that. Of course, I might be convinced to make such changes later, but that's a story of the future, far, far from now.
Would you accept a PR for a transpiler build step for plugins?
There is a package on Hex, but I'm not willing to use that...
@Dalgona, may i ask what's wrong with that package?
Honestly I have not checked the package yet, due to my personal schedules and lots of crazy stuffs after moving to Seoul :sweat_drops: I'll take a look at the package and see if it's an appropriate one for this project.
Can the plugin system be used for processing sass files?