
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@stylexswc/unplugin
Advanced tools
Part of the StyleX SWC Plugin workspace
Unplugin for an unofficial
napi-rs
compiler that includes the StyleX SWC code transformation under the hood.
To install the package, run the following command:
npm install --save-dev @stylexswc/unplugin
To use the plugin, you need to add it to your build tool configuration.
For every plugin have an example of how to use it in
apps/{pluginName}-unplugin-example
folder.
// vite.config.ts
import StylexRsPlugin from '@stylexswc/unplugin/vite';
export default defineConfig({
plugins: [
StylexRsPlugin({
/* options */
}),
],
});
// rollup.config.js
import StylexRsPlugin from '@stylexswc/unplugin/rollup';
export default {
plugins: [
StylexRsPlugin({
/* options */
}),
],
};
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('@stylexswc/unplugin/webpack')({
/* options */
}),
],
};
// rspack.config.js
module.exports = {
/* ... */
plugins: [
require('@stylexswc/unplugin/rspack')({
/* options */
}),
],
};
// nuxt.config.js
export default defineNuxtConfig({
modules: [
[
'@stylexswc/unplugin/nuxt',
{
/* options */
},
],
],
});
This module works for both Nuxt 2 and Nuxt Vite
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('@stylexswc/unplugin/webpack')({
/* options */
}),
],
},
};
// esbuild.config.js
import { build } from 'esbuild';
import StylexRsPlugin from '@stylexswc/unplugin/esbuild';
build({
plugins: [StylexRsPlugin()],
});
rsOptionsPartial<StyleXOptions>[!NOTE] New Features: The
includeandexcludeoptions are exclusive to this NAPI-RS compiler implementation and are not available in the official StyleX Babel plugin.
rsOptions.include(string | RegExp)[]rsOptions.exclude(string | RegExp)[]include pattern.
Patterns are matched against paths relative to the current working directory.fileNamestring'stylex.css'useCSSLayersUseLayersTypefalseextractCSSbooleantruepageExtensionsstring[]['js', 'jsx', 'ts', 'tsx', 'mjs', 'mts']useCssPlaceholderboolean | stringfalsetrue, the plugin will look for the default @stylex; markerglobal.css):/* global.css */
:root {
--brand-color: #663399;
}
body {
margin: 0;
font-family: system-ui, sans-serif;
}
@stylex;
// src/main.ts
import './global.css';
import { App } from './App';
useCssPlaceholder:// vite.config.ts (or webpack.config.js, rspack.config.js, etc.)
import StylexRsPlugin from '@stylexswc/unplugin/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
StylexRsPlugin({
useCssPlaceholder: true, // Uses default '@stylex;' marker
useCSSLayers: true,
}),
],
});
You can specify a custom marker string:
/* global.css */
:root {
--brand-color: #663399;
}
/* INJECT_STYLEX_HERE */
StylexRsPlugin({
useCssPlaceholder: '/* INJECT_STYLEX_HERE */',
useCSSLayers: true,
})
The plugin will replace the marker with the generated StyleX CSS during the build process.
[!NOTE] When
useCssPlaceholderis enabled, the plugin will no longer inject CSS automatically into HTML or emit a separatestylex.cssfile. The CSS is injected into your specified CSS file.
[!IMPORTANT] Migration from
useViteCssPipelineThe
useViteCssPipelineoption (which used virtual CSS modules) has been replaced with theuseCssPlaceholderapproach. The new approach uses real CSS files instead of virtual modules, which provides:
- Better compatibility across all bundlers
- No race conditions or timing issues
- Deterministic builds with stable hashes
To migrate, simply create a CSS file with a marker and set
useCssPlaceholder: true(or use a custom marker string).
// vite.config.ts
import StylexRsPlugin from '@stylexswc/unplugin/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
StylexRsPlugin({
rsOptions: {
dev: process.env.NODE_ENV !== 'production',
// Include only specific directories
include: ['src/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
// Exclude test files and stories
exclude: ['**/*.test.*', '**/*.stories.*', '**/__tests__/**'],
},
useCSSLayers: true,
useCssPlaceholder: true,
}),
],
});
Include only specific directories:
StylexRsPlugin({
rsOptions: {
include: ['src/**/*.tsx', 'app/**/*.tsx'],
},
})
Exclude test and build files:
StylexRsPlugin({
rsOptions: {
exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**', '**/node_modules/**'],
},
})
Using RegExp with lookahead/lookbehind - exclude node_modules except specific packages:
StylexRsPlugin({
rsOptions: {
// Exclude all node_modules except @stylexjs packages
exclude: [/node_modules(?!\/@stylexjs)/],
},
})
Transform only specific packages from node_modules:
StylexRsPlugin({
rsOptions: {
include: [
'src/**/*.{ts,tsx}',
'node_modules/@stylexjs/open-props/**/*.js',
'node_modules/@my-org/design-system/**/*.js',
],
exclude: ['**/*.test.*'],
},
})
Using regular expressions:
StylexRsPlugin({
rsOptions: {
include: [/src\/.*\.tsx$/],
exclude: [/\.test\./, /\.stories\./],
},
})
Combined include and exclude (exclude takes precedence):
StylexRsPlugin({
rsOptions: {
include: ['src/**/*.{ts,tsx}'],
exclude: ['**/__tests__/**', '**/__mocks__/**'],
},
})
MIT — see LICENSE
FAQs
Unplugin for StyleX RS compiler
We found that @stylexswc/unplugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.