Supplying custom parsers through the compiler.compile opts
Closed this issue · 4 comments
After searching a quite a bit, the only way I found to pass custom CSS parsers was to use riot.parsers.css.myCustomCSSParser
which is fine if you have access to the riot
's instance.
However, I'm in a situation where we use esnunes/riotjs-loader and I have no way to modify riot's instance. The only thing I can pass through with webpack is the options
for the compiler.compile
function (done through the query
object in webpack).
Do you think you could make supplying new custom parsers definitions through the opts?
Something like:
{
parsers: {
css: {
myCustomCSSParser: function (tagName, css) {
...
},
...
},
js: {
myCustomJSParser: function (tagName, css) {
...
},
...
},
}
}
There may be other useful use cases (I'm new to Riot).
@GianlucaGuarini @aMarCruz Thanks for considering !
Edit: the need for this is to add postcss
autoprefixer
to SCSS styles defined in the tags. All of that with webpack!
@akmoulai sorry, not in v2. I'm working in a complete rewrite for v3 which will support this and other features. Currently, the compiler API is convoluted and inconsistent, I hope v3 will be more simple and versatile.
@aMarCruz Thanks for your feedback, closing the issue... Please let me know if you would consider a PR!
@GianlucaGuarini I'd really like to set my parsers through parserOptions
, but after going through the code it didn't look like a possibility :(
It'd be really easy to add this feature by merging whatever parsers
that are supplied (as an object) into riot.parsers
.