Closed queckezz closed 9 years ago
I like this, have been thinking about this for a v1.0
as well!
There is one problem with this though... Run for instance babel test/fixtures/index.js
in the project root and babel
will only transform the entry point and not all the required modules as well.
I don't know how to address that at the moment, ideas?
True, this doesn't work currently but you can something like this:
browserify -s css -t babelify test/fixtures/index.js | bin/unistyle -o test.css
note the --standalone
which makes this possible to consume from node. Might be a bit verbose though but definitely more flexible.
I agree with it being more flexible, but quite cumbersome to use.
What do you think about only running babel/register
if there is no stdin
?
Yes better. The more I think about it though, stdin
might be a really rare use case and they could just use the api if we support js objects as input.
See #7 for a simpler change for now
With this PR, unistyle doesn't automatically build js files with babel anymore. Instead it allows arbitrary js to go through.
CLI changes
Supports
stdin
now:API changes
I changed
#compile()
so it just accepts js css definitions as input and css as output (still, when given an output it creates a file) and then let the cli handle the file reading. This way, it can more easily get composed and integrated into a build pipeline (thinking autoprefixer, rework etc.).#compile()
no longer accepts a filename but instead just a css source object:tests
Also added some tests for the cli especially for stdin.
If you agree with the changes I made, I will update the readme accordingly :)