marksmccann / node-sass-extra

A drop-in replacement for node-sass' Node API that adds support for globs, promises and more.
MIT License
2 stars 1 forks source link

Allow for common interpolation patterns in the CLI #16

Open phillipluther opened 5 years ago

phillipluther commented 5 years ago

lerna has this neat feature for dynamically creating the commit message. They use placeholders in a string and replace them with the version number. For example:

lerna version -m "chore(release): publish %v"
# commit message = "chore(release): publish 1.0.0"

What if we did something similar to allow users to dynamically create the output file. This would enabled most users to use the feature directly from the command line. It would also negate the need for additional props like fileExt.

node-sass-extra src/**/*.scss -o dist/%n.min.css

dist/
    my-file.min.css
    my-other-file.min.css

We could possibly use Path's Path Object as the variables to replace.

So, in the case of:

/src/path/to/my-file.scss

These could be the options:

%d (dir) -> src/path/to
%r (root) -> /
%b (base) -> my-file.scss
%n (name) -> my-file
%e (ext) -> .scss

We could also just make up our own, I mean how useful would ext or base be when the file extensions is always going to be .css instead of .scss?

This feature would also enable the preservation of the file tree (since we may default the behavior to flattening the files)

node-sass-extra src/**/*.scss -o dist/%d/%b.css

Would this be passed via the output prop, or somewhere else/new API?

phillipluther commented 5 years ago

Seeded from a discussion on #6 starting with this comment:

https://github.com/marksmccann/node-sass-extra/issues/6#issuecomment-515491817