dougludlow/plugin-sass

Return compiled CSS as string

KarlPurk opened this issue ยท 8 comments

Would you be open to extending the plugin to provide the ability to return the compiled css as a string?

import style from './style.scss!';

@Component({
    template: '...',
    style: [style]
})

Cheers!

I've implemented this in a fork, no tests or bundle support:
kevcjones-archived@fabd142

After playing with this idea last week, I realised that this wouldn't be a very good idea. A better idea is to create a separate plugin for this purpose.

Thank you for the feedback ๐Ÿ‘

I would really like having this implemented in this plugin. Would it be possible for the plugin to detect the import type? So default import vs. module import? If so the functionality should be relatively easy to implement.
Having two separate plugins for importing sass files into my project is no optimal solution and I would like to make use of both ways.

I don't know if this is possible with SystemJS plugins. You can look at the plugin API.

I believe you have to implement fetch and translate but I don't know how to set a result in fetch and give it to translate. The SystemJS internals are not known to me.

Any pull requests are welcome.

This is possible, but the problem with implementing this with a single plugin is what drives the decision to import vs inject?

I originally thought this could be driven at design time by config, but then you are limited to one or the other option.

The best solution would probably be to chain multiple loaders (similar to webpack) but I don't think systemjs currently supports this? - and this would still require two loaders, one for scss and one for injecting into head.

For our use case, my colleague developed plugin-scss which allows scss to be imported as a string. We can then inject it into the head manually if we desire or work with the compiled scss directly.

Ah I understand ๐Ÿ‘
This is indeed a different approach as this plugin was designed for. Also I don't know if it's a good idea to mix the behaviour of this plugin with the different approach of your plugin so I think it's the best solution to have two different plugins for that. Maybe in the future it is possible to have chained multiple loaders in SystemJS / jspm so we can merge together ๐Ÿ˜Ž

Watching that space ๐Ÿ˜Ž

If nothing else the variation we have is useful for our needs with angular2 and it was highly educating to write when learning JSPM and SystemJS. So thanks for the starting point. ๐Ÿ‘