Skip to content
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

Supplying custom parsers through the compiler.compile opts #86

Closed
akmoulai opened this issue Sep 27, 2016 · 4 comments
Closed

Supplying custom parsers through the compiler.compile opts #86

akmoulai opened this issue Sep 27, 2016 · 4 comments

Comments

@akmoulai
Copy link

akmoulai commented Sep 27, 2016

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!

@aMarCruz
Copy link
Contributor

@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.

@akmoulai
Copy link
Author

@aMarCruz Thanks for your feedback, closing the issue... Please let me know if you would consider a PR!

@GianlucaGuarini
Copy link
Member

GianlucaGuarini commented Sep 28, 2016

@aMarCruz btw this feature should be already implemented 124e620 and the option name is called parserOptions

UPDATE: nevermind parsetOptions does something else sorry for the confusion

@akmoulai
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants