Serum icon indicating copy to clipboard operation
Serum copied to clipboard

sass processor?

Open bcardarella opened this issue 5 years ago • 6 comments

Can the plugin system be used for processing sass files?

bcardarella avatar Jun 08 '19 20:06 bcardarella

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.

  1. 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.

  2. At that moment, assets are already copied to /path/to/output/assets directory. And that directory may contain any unprocessed sass files.

  3. 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.

Dalgona avatar Jun 12 '19 09:06 Dalgona

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

bcardarella avatar Jun 12 '19 10:06 bcardarella

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.

Dalgona avatar Jun 12 '19 10:06 Dalgona

Would you accept a PR for a transpiler build step for plugins?

bcardarella avatar Jun 12 '19 11:06 bcardarella

There is a package on Hex, but I'm not willing to use that...

@Dalgona, may i ask what's wrong with that package?

igalic avatar Jun 12 '19 15:06 igalic

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.

Dalgona avatar Jun 16 '19 01:06 Dalgona