@tkow/stylex-next-compiler-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

@tkow/stylex-next-compiler-plugin

This is extended of @stylex/nextjs-plugin to work arround with nextjs compiler.

Documentation Website

https://stylexjs.com

Installation

Install the package by using:

npm install --save-dev @tkow/stylex-next-compiler-plugin @stylexjs/babel-plugin

Custom Babel Compiler Configuration

Add the following to your .babelrc.js

module.exports = {
  presets: ['next/babel'],
  plugins: [
    [
      '@stylexjs/babel-plugin',
      {
        dev: process.env.NODE_ENV === 'development',
        runtimeInjection: false,
        genConditionalClasses: true,
        unstable_moduleResolution: {
          type: 'commonJS',
          rootDir: __dirname,
        },
      },
    ],
  ],
};

Next Compiler Configuration (SWC)

Without .babelrc.js and other babel configuration files.

Add the following to your next.config.js

const stylexPlugin = require('@tkow/stylex-next-compiler-plugin');

module.exports = stylexPlugin({
  rootDir: process.env.cwd(),
  babelrc: false,
  babelOptions: {
    dev: process.env.NODE_ENV === 'development',
    runtimeInjection: false,
    genConditionalClasses: true,
    unstable_moduleResolution: {
      type: 'commonJS',
      rootDir: __dirname,
    },
  }
})({});

When you want to use Next-Compiler(SWC), you should specify babelrc option false. The babelOptions is optional and the schema is defined by @stylexjs/babel-plugin.

Package Sidebar

Install

npm i @tkow/stylex-next-compiler-plugin

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

32.7 kB

Total Files

19

Last publish

Collaborators

  • tkow