Another esbuild plugin for your styling with CSS,SASS,LESS,STYLUS
npm install esbuild-style-pluginpostcss.config.js config file - if path is provided in postcssConfigFile option
npm i -D esbuild-style-plugin
ts
import stylePlugin from 'esbuild-style-plugin'
//const stylePlugin = require('esbuild-style-plugin')
esbuild.build({
plugins: [
stylePlugin()
]
})
`
$3
- extract default to true
- cssModulesMatch match .module. by default
- cssModulesOptions
- renderOptions
- sassOptions
- lessOptions
- stylusOptions
- postcss
- plugins array of postcss accepted plugins
- parser | syntax parse source css - use with postcss-scss
- postcssConfigFile absolute path to postcss.config.js or true for using root folder path
Preprocessor
The plugin does not come with all preprocessor installed since you might not need all of them.
Install the ones you need!
- SASS npm i -D sass
- LESS npm i -D less
- STYLUS npm i -D stylus
CSS Modules
$3
A specific use case that this plugin covers is SSR.
Using extract: false will not process css on server side but will keep css mapping for css modules.
PostCSS
The plugin is using PostCSS to handle css modules files.
You can include any other plugins with the postcss option.
$3
Do not use cssnano plugin. It won't work and if it did it minifies all files seperatly (slow not efficient).
Just let esbuild minify and do his job.
$3
If you want to be able to use import styles from 'styles.module.sass' without any errors
Just add esbuild-style-plugin to your types in tsconfig.json`