@stylexswc/nextjs-plugin
Version:
StyleX plugin for Next.js powered by a Rust NAPI-RS/SWC compiler. Supports Webpack, Rspack, and Turbopack builds with CSS extraction.
37 lines (36 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const withStyleX = (pluginOptions) => (nextConfig = {}) => {
const reactLoaders = [
{
loader: '@stylexswc/turbopack-plugin/loader',
// @ts-expect-error - StyleXPluginOption is compatible with Next.js' Turbopack loader options, but types are not aligned yet
options: {
...pluginOptions,
},
},
];
return {
...nextConfig,
turbopack: {
...nextConfig?.turbopack,
rules: {
'*.ts': {
loaders: reactLoaders,
},
'*.tsx': {
loaders: reactLoaders,
},
'*.js': {
loaders: reactLoaders,
},
'*.jsx': {
loaders: reactLoaders,
},
},
},
};
};
exports.default = withStyleX;
module.exports = withStyleX;
module.exports.default = withStyleX;