Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/eryue0220/unplugin-stylex

StyleX integration for Vite, esbuild, webpack, rollup and rspack.
https://github.com/eryue0220/unplugin-stylex

Last synced: about 1 month ago
JSON representation

StyleX integration for Vite, esbuild, webpack, rollup and rspack.

Lists

README

        

# unplugin-stylex · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eryue0220/unplugin-stylex/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/unplugin-stylex.svg?style=flat)](https://www.npmjs.com/package/unplugin-stylex)

> [!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

```shell
npm install unplugin-stylex --save-dev
```

or with yarn:

```shell
yarn add unplugin-stylex --save-dev
```

or with pnpm:

```shell
pnpm i unplugin-stylex --save-dev
```

## Configuration

Vite

```js
// vite.config.js
import { defineConfig } from 'vite'
import stylexPlugin from 'unplugin-stylex/vite'

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

esbuild

```js
// esbuild.config.js
import { build } from 'esbuild'
import stylexPlugin from 'unplugin-stylex/esbuild'

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

rspack

```js
// rspack.config.js
import stylexPlugin from 'unplugin-stylex/rspack'

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

rollup

```js
// rollup.config.js
import stylexRollupPlugin from 'unplugin-stylex/rollup'

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

webpack

```js
// webpack.config.js
import stylexWebpackPlugin from 'unplugin-stylex/webpack'

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

## Usage

More detail usage can check [examples](https://github.com/eryue0220/unplugin-stylex/tree/main/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

- [@stylexjs/rollup-plugin](https://github.com/facebook/stylex/tree/main/packages/rollup-plugin)
- [vite-plugin-stylex](https://github.com/HorusGoul/vite-plugin-stylex)