ludohenin / gulp-inline-ng2-template

Gulp plugin to inline HTML and CSS into Angular 2 component decorators
MIT License
126 stars 26 forks source link

Support for merging when using both styleUrl AND style #63

Open sxgrant opened 8 years ago

sxgrant commented 8 years ago

Due to the way I'm trying to centralise/share some CSS, I want to support including styleUrls that are specific to a Component, as well as some hard-coded style CSS from a support class.

However, if both style and styleUrls are present, then the inline-ng2-template creates a duplicate style property, instead of merging with the pre-existing one.

I'm looking at instead having a constant that contains a reference to a small CSS file to work around this limitation, so that everything is still in styleUrls, but I'd love to have the above behaviour supported.

sxgrant commented 8 years ago

Just an update; even if the above behaviour is supported, I think I'd still hit an issue with inline-ng2-template not having variables resolved at the time that it runs.

I basically want to have

@Component ({ ... styles: [ExternalClass.staticCss], styleUrls: ['./component.css'], ...

but even if the inline-ng2-template was to merge the two, it would be doing so while not knowing how to resolve what ExternalClass.staticCss actually contains, if I understand it properly. So a proper solution to my problem looks like it would need to involve a templateFunction as well?

ludohenin commented 8 years ago

Yeah, this is in the Todo. I don't have much time to spend on this. Would you send a PR? this is where it should be done https://github.com/ludohenin/gulp-inline-ng2-template/blob/master/parser.js#L225