-
Notifications
You must be signed in to change notification settings - Fork 155
Add support for <style> and the Stylus lang #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR 👍
Stylus needs to be added as a devDependency, and could you add some tests for a plain style block, without stylus
Thanks for the feedback! |
Thanks 🙂 |
Great Work! |
@LinusBorg Thanks! :) |
@@ -78,5 +98,20 @@ module.exports = function (src, path) { | |||
} | |||
} | |||
|
|||
if (Array.isArray(parts.styles) && parts.styles.length > 0) { | |||
const styleStr = parts.styles.map(ast => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should only convert style partss that acually have a "module" attribute, right?
Otherwise we would create a $styles
object on a component that onnly has "normal" styles like <style lang="scss">
.
|
||
output += '\n;(function() {' + | ||
'\nvar render = __vue__options__.render' + | ||
'\n__vue__options__.render = function(h) {' + styleStr + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding it to the render function, I think we should create a beforeCreate() callback that adds the property during intialization of the component.
That's essentially what vue-loader does, it would look something like this:
output += '\n;(function() {' +
'\nvar existing = __vue__options__.beforeCreate' +
'\nvar styleFn = function () { ' + styleStr + ' })' +
'\n__vue__options__.beforeCreate = existing ? [].concat(existing, styleFn) : [styleFn]' +
'})()'
This would ensure that the style is also available before render, e.g. to be accessed from within some method or a created()
hook.
Well, I think since neither one of those are use cases I'm currently in need of, I just didn't remember them... Thanks for the review 👍 |
Fixes #38