Home

Awesome

unplugin-stylex · GitHub license npm version

[!WARNING]
This plugin is in early development and may not work as expected. Please report any issues you find.

Installation

Install the package from the following command

npm install unplugin-stylex --save-dev

or with yarn:

yarn add unplugin-stylex --save-dev

or with pnpm:

pnpm i unplugin-stylex --save-dev

Configuration

<details> <summary>Vite</summary><br>
// vite.config.js
import { defineConfig } from 'vite'
import stylexPlugin from 'unplugin-stylex/vite'

export default defineConfig({
  plugins: [
    stylexPlugin({ /* options */}),
  ],
})

</br></details>

<details> <summary>esbuild</summary><br>
// esbuild.config.js
import { build } from 'esbuild'
import stylexPlugin from 'unplugin-stylex/esbuild'

export default {
  plugins: [
    stylexPlugin({ /* options */ }),
  ],
}

</br></details>

<details> <summary>farm</summary><br>
// farm.config.js
import { defineConfig } from '@farmfe/core'
import stylexPlugin from 'unplugin-stylex/farm'

export default defineConfig({
  // other rollup config
  plugins: [
    stylexPlugin({ /* options */}),
  ],
})

</br></details>

<details> <summary>rspack</summary><br>
// rspack.config.js
import stylexPlugin from 'unplugin-stylex/rspack'

module.exports = {
  // other rspack config
  plugins: [
    stylexPlugin({ /* options */}),
  ],
}

</br></details>

<details> <summary>rollup</summary><br>
// rollup.config.js
import stylexRollupPlugin from 'unplugin-stylex/rollup'

export default {
  // other rollup config
  plugins: [
    stylexRollupPlugin({ /* options */}),
  ],
}

</br></details>

<details> <summary>webpack</summary><br>
// webpack.config.js
import stylexWebpackPlugin from 'unplugin-stylex/webpack'

module.exports = {
  // other webpack config
  plugins: [
    stylexWebpackPlugin({ /* options */}),
  ],
}

</br></details>

Usage

More detail usage can check examples

Options

Current support argument, which may have change in the future

options.dev

options.stylex.runtimeInjection

options.stylex.classNamePrefix

options.stylex.useCSSLayers

options.stylex.babelConfig

options.stylex.stylexImports

options.stylex.unstable_moduleResolution

Acknowledgments