Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS not apply to elements in V6 with Next.js #1387

Open
mydearxym opened this issue Dec 12, 2023 · 5 comments
Open

CSS not apply to elements in V6 with Next.js #1387

mydearxym opened this issue Dec 12, 2023 · 5 comments
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided platform: next.js 🛠️ Issue related to next.js

Comments

@mydearxym
Copy link

mydearxym commented Dec 12, 2023

hi team,

recently i try to replace styled-component with linaria, but css seems not work.

Environment

minimal Nextjs@14 with latest Linaria@6

  • Linaria version: 6.0.0
  • Bundler (+ version): webpack@5
  • Node.js version: v20.3.1
  • OS: Mac

.babelrc:

{
  "presets": ["next/babel", "@wyw-in-js"],
  "plugins": []
}

wyw-in-js.config.js

module.exports = {
  evaluate: true,
  displayName: true,
};

next.js config

const withLinaria = require("next-with-linaria");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");

const nextConfig = {
  webpack: (config, options) => {
    config.plugins.push(new MiniCssExtractPlugin());
    config.module.rules.push(
      {
        test: /\.ts?$/,
        use: [
          {
            loader: "@wyw-in-js/webpack-loader",
          },
        ],
      },
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"],
      }
    );

    return config;
  },
};

module.exports = withLinaria(nextConfig);

related packages:

  "dependencies": {
    "@linaria/core": "^6.0.0",
    "@linaria/react": "^6.0.0",
    "next": "14.0.4",
    "next-with-linaria": "^0.6.0",
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "@wyw-in-js/babel-preset": "^0.2.2",
    "@wyw-in-js/webpack-loader": "^0.2.2",

Description

project is running, but seems Linaria only recognized element tag, the CSS rules are not apply to it

image

image

Reproducible Demo

https://github.com/groupher/wyw-demo

@mydearxym mydearxym added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Dec 12, 2023
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler platform: next.js 🛠️ Issue related to next.js and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Dec 12, 2023
@harumijang
Copy link

Am facing the same issue with Next 14. Commenting to follow

@JonCognioDigital
Copy link

Anyone solved this yet? Would be great to see a reference implementation.

@victor-bts
Copy link

Was only able to get it with page routing and next.js 14 using https://www.npmjs.com/package/next-with-linaria. Once I started to use app routing, this method no longer worked. I ended up switching Linaria over to Emotion. Implementation and import names are compatible so there was almost zero re-work. I know the bundle size implication of Emotion but due to the variety of our components (small), we chose to eat the cost as a trade-off for next.js 14 compatibility. I would have liked to have both but it's not within my pay grade to ensure compatibility between the two.

@straxico
Copy link

anyone can work with next 14 app router and linaria?

@aberba
Copy link

aberba commented Jul 29, 2024

I think there needs to be an SWC plugin. There was one but currently outdated: https://github.com/arendjr/linaria-swc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler needs: complete repro 🖥️ Issue need to have complete repro provided platform: next.js 🛠️ Issue related to next.js
Projects
None yet
Development

No branches or pull requests

6 participants