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

How to compile React Component with less or css? #6

Closed
YardWill opened this issue Jun 12, 2018 · 3 comments
Closed

How to compile React Component with less or css? #6

YardWill opened this issue Jun 12, 2018 · 3 comments

Comments

@YardWill
Copy link

How to compile React Component with less or css? Our UI Library in private npm registry just compiled to es5 and we didn't compile less(We compiled less in our business project with webpack).

@pedronauck
Copy link
Member

pedronauck commented Jun 12, 2018

You can modify your bundler config and put less, sass or css modules loaders at rules... I didn't have much time, but my idea is create something like docz-plugin-less, docz-plugin-sass, docz-plugin-cssmodules in the near future...

But if you want to modify your bundler config, just use the modifyBundlerConfig on doczrc.js:

// doczrc.js
export default {
  modifyBundlerConfig: (config) => {
    /* put your custom loaders logic here */
    return config
  }
}

@renatorib
Copy link
Contributor

renatorib commented Jun 12, 2018

@YardWill

You need to put the loader of sass or less.
Here is an example using sass:

// doczrc.js

export default {
  modifyBundlerConfig: (config) => {
    config.module.rules.push({
      test: /\.scss$/,
      use: ["style-loader", "css-loader", "sass-loader"]
    })
    
    return config
  }
}
yarn add style-loader css-loader sass-loader --dev

Read more here: https://github.com/webpack-contrib/sass-loader

@pedronauck
Copy link
Member

After released v0.2.11 you can use docz-plugin-css to configure your CSS just by adding a plugin ✌️

@YardWill

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