docz-plugin-css
TypeScript icon, indicating that this package has built-in type declarations

0.11.0 • Public • Published

docz-plugin-css

Docz plugin to parse css files inside your documents

Examples

Instalation

First of all, install plugin:

$ yarn add docz-plugin-css --dev

After that, use the plugin on your doczrc.js:

// doczrc.js
import { css } from 'docz-plugin-css'
 
export default {
  plugins: [
    css({
      preprocessor: 'postcss',
      cssmodules: true,
      loaderOpts: {
        /* whatever your preprocessor loader accept */
      }
    })
  ]
}

Choosing PostCSS, Sass, Less or Stylus

Do you can choose how preprocessor your bundler will use just by changing the preprocessor property at the plugin definition:

// doczrc.js
import { css } from 'docz-plugin-css'
 
export default {
  plugins: [
    css({
      preprocessor: 'sass'
    })
  ]
}

Using CSS Modules

To use css modules, just turn on cssmodules property on your project configuration:

// doczrc.js
import { css } from 'docz-plugin-css'
 
export default {
  plugins: [
    css({
      preprocessor: 'sass',
      cssmodules: true
    })
  ]
}

After that, to import styles from css modules, just use .module.{preprocessor-ext} on your files

---
name: Button
----
 
import { Playground } from 'docz'
 
import { Button } from './Button'
import { styles } from './styles.module.css'
 
# Button 
 
Example of Button component with custom class!
 
<Playground>
  <Button className={styles.custom}>
    Click me
  </Button>
</Playground>

If you don't pass .module in front of the preprocessor extension, bundler will don't parse your css as cssmodule!

Multiple pre-processor

You can still use multiple pre-processor together in the same configuration:

// doczrc.js
import { css } from 'docz-plugin-css'
 
export default {
  plugins: [
    css({ preprocessor: 'sass' }),
    css({ preprocessor: 'stylus' }),
  ]
}

Api

Params

preprocessor

  • Type: postcss | sass | less | stylus
  • Default: postcss

Use to define the preprocessor you want to use

cssmodules

  • Type: Boolean
  • Default: false

Use this option if you want to use css modules

loaderOpts

  • Type: { [key:string]: any }
  • Default: {}

Custom options passed on pre-processor loader configuration

cssOpts

  • Type: { [key:string]: any }
  • Default: {}

Custom options passed on css-loader configuration

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.11.0163latest
0.10.0-beta.02beta

Version History

VersionDownloads (Last 7 Days)Published
0.11.0163
0.10.33
0.10.22
0.10.12
0.10.02
0.10.0-beta.02
0.9.62
0.9.42
0.9.4-beta.12
0.9.4-beta.02
0.9.32
0.9.22
0.9.12
0.9.02
0.9.0-beta.12
0.9.0-beta.02
0.8.02
0.7.12
0.7.02
0.6.22
0.6.02
0.5.92
0.5.72
0.5.62
0.5.54
0.5.42
0.5.22
0.5.12
0.5.02
0.4.02
0.3.42
0.3.32
0.3.22
0.3.12
0.2.112
0.2.102

Package Sidebar

Install

npm i docz-plugin-css

Weekly Downloads

206

Version

0.11.0

License

MIT

Unpacked Size

22.2 kB

Total Files

12

Last publish

Collaborators

  • pedronauck