Docz: How to compile React Component with less or css?

Created on 12 Jun 2018  路  3Comments  路  Source: doczjs/docz

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

Most helpful comment

@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

All 3 comments

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
  }
}

@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

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

@YardWill

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mariusespejo picture mariusespejo  路  3Comments

regrettably picture regrettably  路  3Comments

mquandalle picture mquandalle  路  3Comments

ilyanoskov picture ilyanoskov  路  3Comments

danburzo picture danburzo  路  3Comments