0.11.1 • Published 4 months ago

@stylexjs/esbuild-plugin v0.11.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

@stylexjs/esbuild-plugin

Use StyleX with esbuild bundler.

This plugin transforms files that contain stylexjs imports and generates a stylexjs CSS bundle.

Installation

npm install --save-dev @stylexjs/esbuild-plugin

Usage

import esbuild from 'esbuild';
import stylexPlugin from '@stylexjs/esbuild-plugin';
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));

esbuild.build({
  entryPoints: ['src/index.js'],
  bundle: true,
  outfile: './build/bundle.js',
  minify: true,
  plugins: [
    stylexPlugin({
      // If set to 'true', bundler will inject styles in-line
      // Do not use in production
      dev: false,
      // Required. File path for the generated CSS file
      generatedCSSFileName: path.resolve(__dirname, 'build/stylex.css'),
      // Aliases for StyleX package imports
      // default: '@stylexjs/stylex'
      stylexImports: ['@stylexjs/stylex'],
      // Required for CSS variable support
      unstable_moduleResolution: {
        // type: 'commonJS' | 'haste'
        // default: 'commonJS'
        type: 'commonJS',
        // The absolute path to the root of your project
        rootDir: __dirname,
      },
    }),
  ],
});

Plugin Options

It inherits all options from @stylexjs/babel-plugin and can be found here 🔗. Along with other options like

generatedCSSFileName

generatedCSSFileName: string // Default: 'stylex.css'

The name of the output css file.


useCSSLayers

useCSSLayers: boolean // Default: false

Enabling this option switches Stylex from using :not(#\#) to using @layers for handling CSS specificity.


babelConfig

babelConfig: {
  plugins: PluginItem[],
  presets: PluginItem[]
} // Default: { plugins: [], presets: [] }

List of custom babel plugins and presets which can be used during code transformation.


You can see the example usage here.

0.11.1

4 months ago

0.11.0

4 months ago

0.10.1

5 months ago

0.10.0-beta.2

7 months ago

0.10.0-beta.1

7 months ago

0.10.0

6 months ago

0.9.3

8 months ago

0.9.0

8 months ago

0.9.2

8 months ago

0.9.1

8 months ago

0.9.0-beta.1

8 months ago

0.8.0

9 months ago

0.7.5

12 months ago

0.7.1

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.5.1

1 year ago

0.5.0-alpha.4

1 year ago

0.5.0-alpha.3

1 year ago

0.5.0-alpha.2

1 year ago

0.5.0-alpha.1

1 year ago