The current build environment for stylex in this repository is outdated.
Configuration of the latest framework:
- next@16.3.3
- stylex@0.19.0
In the next.js environment, the nextjs-plugin for stylex has been deprecated, and babel-plugin and postcss-plugin are now required.
It would be helpful if you could build it using this method.
package.json:
@stylexjs/open-props was deprecated and has been removed.
{
"name": "next-stylex-benchmark",
"version": "0.1.0",
"private": true,
"scripts": {
"predev": "rimraf .next",
"prebuild": "rimraf .next",
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"@stylexjs/stylex": "0.19.0",
"next": "16.3.3",
"react": "19.2.4",
"react-dom": "19.2.4"
},
"devDependencies": {
"@stylexjs/babel-plugin": "0.19.0",
"@stylexjs/postcss-plugin": "0.19.0",
"@types/node": "26.2",
"@types/react": "^19",
"@types/react-dom": "^19",
"rimraf": "6.1",
"typescript": "7.0"
}
}
Delete and replace .babelrc.js
babel.config.js:
const path = require("node:path");
module.exports = {
presets: ["next/babel"],
plugins: [
[
"@stylexjs/babel-plugin",
{
dev: process.env.NODE_ENV !== "production",
runtimeInjection: false,
genConditionalClasses: true,
treeshakeCompensation: true,
aliases: {
"@/*": [path.join(__dirname, "*")],
},
unstable_moduleResolution: {
type: "commonJS",
},
},
],
],
};
postcss.config.js:
// @stylexjs/postcss-plugin
module.exports = {
plugins: {
"@stylexjs/postcss-plugin": {
include: ["app/**/*.{js,jsx,ts,tsx}"],
exclude: ["**/node_modules/**", "**/.next/**"],
},
},
};
globals.css:
@stylex; /* postcss injection point */
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
It can also write it in next.config.ts.
next.config.js:
// Do nothing here (it's all handled by babel-plugin and postcss-plugin)
/** @type {import('next').NextConfig} */
const nextConfig = {}
module.exports = nextConfig
The current build environment for stylex in this repository is outdated.
Configuration of the latest framework:
In the next.js environment, the nextjs-plugin for stylex has been deprecated, and babel-plugin and postcss-plugin are now required.
It would be helpful if you could build it using this method.
package.json:
@stylexjs/open-propswas deprecated and has been removed.{ "name": "next-stylex-benchmark", "version": "0.1.0", "private": true, "scripts": { "predev": "rimraf .next", "prebuild": "rimraf .next", "dev": "next dev", "build": "next build", "start": "next start" }, "dependencies": { "@stylexjs/stylex": "0.19.0", "next": "16.3.3", "react": "19.2.4", "react-dom": "19.2.4" }, "devDependencies": { "@stylexjs/babel-plugin": "0.19.0", "@stylexjs/postcss-plugin": "0.19.0", "@types/node": "26.2", "@types/react": "^19", "@types/react-dom": "^19", "rimraf": "6.1", "typescript": "7.0" } }Delete and replace
.babelrc.jsbabel.config.js:
postcss.config.js:
globals.css:
It can also write it in next.config.ts.
next.config.js: