v2.0 support rollup v1 or above, but it prints deprecated warning from rollup v2.
Breaking change: v3.0 only support rollup v2, and the extract path based on bundle root
the location of the generated file outside the bundle directory not allowed in rollup v2.
Note that the generated CSS will be injected to <head> by default, and the CSS string is also available as default export unless extract: true:
// Inject to `<head>` and also available as `style`import style from './style.css'
It will also automatically use local PostCSS config files.
Extract CSS
// for v2postcss({ extract: true, // Or with custom file name, it will generate file relative to bundle.js in v3 extract: 'dist/my-custom-file-name.css'})// for v3import path from 'path'postcss({ extract: true, // Or with custom file name extract: path.resolve('dist/my-custom-file-name.css')})
CSS modules
postcss({ modules: true, // Or with custom options for `postcss-modules` modules: {}})
With Sass/Stylus/Less
Install corresponding dependency:
For Sass install node-sass: yarn add node-sass --dev
For Stylus Install stylus: yarn add stylus --dev
For Less Install less: yarn add less --dev
That's it, you can now import .styl.scss.sass.less files in your library.
imports
For Sass/Scss Only.
Similar to how webpack's sass-loader works, you can prepend the path with ~ to tell this plugin to resolve in node_modules:
@import "~bootstrap/dist/css/bootstrap";
Options
extensions
Type: string[]
Default: ['.css', '.sss', '.pcss']
This plugin will process files ending with these extensions and the extensions supported by custom loaders.