Better integrations in 2025? #825
Replies: 6 comments 6 replies
-
A postcss plugin was recently added, although it has not yet been documented - #781 |
Beta Was this translation helpful? Give feedback.
-
@realChakrawarti Happily using Vite with minimal setup overhead: 📑 import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import stylex from "vite-plugin-stylex";
export default defineConfig({
plugins: [
react(),
stylex(),
],
server: { port: 3000 },
preview: { port: 3000 },
}); 📑 /* https://github.com/HorusGoul/vite-plugin-stylex?tab=readme-ov-file#including-stylex-styles-in-your-project */
@stylex stylesheet; And import the StyleX CSS file once. That's about all you need to do to get started. Just install: npm i --save-dev @stylexjs/stylex vite-plugin-stylex |
Beta Was this translation helpful? Give feedback.
-
The following is my personal opinion. Like Currently vite's integration relies on virtual module, but you can't ensure that these vite's based frameworks will break this behavior. (So based on css it self can using vite's internal css pipeline) Anyway, I think if using vite plug-in should consider split it as multiple plugin. Split as |
Beta Was this translation helpful? Give feedback.
-
Wish you all a happy new year! |
Beta Was this translation helpful? Give feedback.
-
As @nonzzz mentioned, Vite integrations are pretty problematic because of how various frameworks use it differently. One of the biggest challenges is the fact that Vite does not bundle in dev mode. With the upcoming changes to Vite and Rolldown which will bundle even in development, I am hopefuly that a good Vite integration will become possible. 🤞 |
Beta Was this translation helpful? Give feedback.
-
I set up the Note, my application is fully client rendered. I'm not sure if any more configuration is required for ssr/frameworks Installationnpm install @stylexjs/stylex npm install --save-dev @stylexjs/postcss-plugin autoprefixer npm install --save-dev @babel/core @babel/preset-react @babel/preset-typescript Config📑 import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react({
babel: {
babelrc: true,
configFile: true,
},
}),
],
}); 📑 export default {
plugins: {
"@stylexjs/postcss-plugin": {
include: ["src/**/*.{js,jsx,ts,tsx}"],
useCSSLayers: true, // Optional
},
autoprefixer: {},
},
}; 📑 export default {
presets: [
[
"@babel/preset-react",
{
runtime: "automatic",
},
],
"@babel/preset-typescript", // If you're using typescript
],
plugins: [
[
"@stylexjs/babel-plugin",
{
runtimeInjection: false,
dev: process.env.NODE_ENV === "development",
test: false,
unstable_moduleResolution: {
type: "commonJS",
rootDir: process.cwd(),
},
},
],
],
}; Set upAdd the stylex directive to your index.css file, or whatever the equivalent of that is for you in your project. /* index.css */
@stylex; Import the css file with the stylex directive into the entry point of your application. // main.tsx
import './index.css'; Additional
|
Beta Was this translation helpful? Give feedback.
-
I heard about stylex about a year ago and have been checking from time to time. What I feel lacks is templates and integration guides.
For example, I just started a vite v6 + react v19 hobby project and wanted something new for styling and sadly I am struggling to set it up. Skill issues? Maybe, but would really love some integration guides/ templates.
With the year ending, I am hopeful that coming year 2025, we would get better updates on the setup side of things.
Merry Christmas and a happy new year!
Beta Was this translation helpful? Give feedback.
All reactions