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

Next.js 13 - Builds not outputting css on Windows #1086

Closed
2 tasks done
exneval opened this issue May 10, 2023 · 18 comments · Fixed by #1180
Closed
2 tasks done

Next.js 13 - Builds not outputting css on Windows #1086

exneval opened this issue May 10, 2023 · 18 comments · Fixed by #1180
Assignees
Labels
nextjs Issue related to NextJS

Comments

@exneval
Copy link

exneval commented May 10, 2023

Describe the bug

  • Clone the "should be working repo" in Windows

  • Inspect with DevTools, and see footer class being generated without styles

image

Need help @markdalgleish @SuttonJack

Reference in discussion

Edit:
Running the app inside container seems fine.

Reproduction

https://github.com/SuttonJack/vanilla-extract-app-dir

System Info

Windows 11

Used Package Manager

pnpm

Logs

No response

Validations

@matheus-bruscke
Copy link

I'm having the same issue here on Windows 10

@askoufis askoufis added nextjs Issue related to NextJS and removed pending triage labels May 15, 2023
@askoufis askoufis self-assigned this May 15, 2023
@askoufis
Copy link
Contributor

I'm still in the process of setting up a windows dev environment, but I'll take a look at it when I can.

@i-bsd
Copy link

i-bsd commented May 23, 2023

Also happening in Linux (Ubuntu).

@askoufis
Copy link
Contributor

askoufis commented May 23, 2023

Also happening in Linux (Ubuntu).

It works fine for me, on MacOS though. I wouldn't expect it to behave very differently between ubuntu and macos.

Also general update, I'm reproduce the issue on windows. It's odd that classnames are in the markup, but there are no CSS files in the document head. This seems like an issue with Next, but it might not be. We've made a discussion in the next repo about Vanilla Extract support, pointing to various next bugs vercel/next.js#49892.

@mtripg6666tdr
Copy link

mtripg6666tdr commented Jul 18, 2023

Same here on Windows 11, but not be reproduced on Ubuntu 22.04 (WSL).
Could everyone investigate this issue more? I also want to help with solving this issue as possible.

@NotNite
Copy link

NotNite commented Jul 23, 2023

Same here on Windows 10 (19045.3208), Node.js 19.2.0, latest versions of @vanilla-extract/css/next/@vanilla-extract/next-plugin.

@Sharlottes
Copy link

Same here.
reproduction: https://github.com/Sharlottes/ve-missing-style-reproduction
interestingly, the deployment on the Vercel works well.
https://ve-missing-style-reproduction.vercel.app/

@GeeWizWow
Copy link
Contributor

still doing some debugging, but it's server components specifically that are failing, adding a 'use client' directive results in stylesheets being generated.

@leljak
Copy link

leljak commented Aug 6, 2023

still doing some debugging, but it's server components specifically that are failing, adding a 'use client' directive results in stylesheets being generated.

This works for components, what about global styles, any workaround?

@GeeWizWow
Copy link
Contributor

still doing some debugging, but it's server components specifically that are failing, adding a 'use client' directive results in stylesheets being generated.

This works for components, what about global styles, any workaround?

I did find a workaround, but ended not needing it, as it's a bit of an inelegant hack, but if you use a wildcard import and ensure you use the resulting variable in some capacity, it should pickup the globalStyles

import * as styles from './global.css';

console.log(styles)

@leljak
Copy link

leljak commented Aug 6, 2023

still doing some debugging, but it's server components specifically that are failing, adding a 'use client' directive results in stylesheets being generated.

This works for components, what about global styles, any workaround?

I did find a workaround, but ended not needing it, as it's a bit of an inelegant hack, but if you use a wildcard import and ensure you use the resulting variable in some capacity, it should pickup the globalStyles

import * as styles from './global.css';

console.log(styles)

Uh, really ugly, but it works, thank you!

@syfxlin
Copy link
Contributor

syfxlin commented Sep 9, 2023

I've recently been migrating my blog from Gatsby to Next.js and I'm having the same problem. I found a solution at style9-webpack (SukkaW/style9-webpack#1) and made another Next.js plugin for vanilla-extract that works fine on Windows/Linux/macOS, if you're having a similar problem, you can try @syfxlin/next-plugin-vanilla-extract.

@GeeWizWow
Copy link
Contributor

I've recently been migrating my blog from Gatsby to Next.js and I'm having the same problem. I found a solution at style9-webpack (SukkaW/style9-webpack#1) and made another Next.js plugin for vanilla-extract that works fine on Windows/Linux/macOS, if you're having a similar problem, you can try @syfxlin/next-plugin-vanilla-extract.

Is this something that can be contributed here? I'm sure many of us would prefer not to see fragmentation, especially as vanilla-extract and or next continue to evolve

@syfxlin
Copy link
Contributor

syfxlin commented Sep 10, 2023

Hi @GeeWizWow, @syfxlin/next-plugin-vanilla-extract hasn't been fully tested, for example I'm not sure if it works in the Next.js Pages Directory yet. Once it's confirmed to be reliable, I can contribute here, thanks!

@sherluok
Copy link

sherluok commented Oct 2, 2023

I gave up next-plugin and instead write webpack transformer with webpack-plugin directly. It works for now, just for reference, do not use this in production:

// 2023/10/03; windows 11; next@13.5.3; @vanilla-extract/webpack-plugin@2.3.1

const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin/next');
const { default: MiniCssExtractPlugin } = require('next/dist/build/webpack/plugins/mini-css-extract-plugin');

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack(config) {
    config.plugins.unshift(new MiniCssExtractPlugin());
    config.plugins.unshift(new VanillaExtractPlugin());

    config.module.rules.unshift({
      test: /vanilla\.virtual\.css$/,
      use: [
        MiniCssExtractPlugin.loader,
        require.resolve('css-loader'),
        VanillaExtractPlugin.loader,
      ],
    });
    return config;
  },
};

module.exports = nextConfig;

@askoufis
Copy link
Contributor

askoufis commented Oct 15, 2023

I gave up next-plugin and instead write webpack transformer with webpack-plugin directly. It works for now, just for reference, do not use this in production:

// 2023/10/03; windows 11; next@13.5.3; @vanilla-extract/webpack-plugin@2.3.1

const { VanillaExtractPlugin } = require('@vanilla-extract/webpack-plugin/next');
const { default: MiniCssExtractPlugin } = require('next/dist/build/webpack/plugins/mini-css-extract-plugin');

/** @type {import('next').NextConfig} */
const nextConfig = {
  webpack(config) {
    config.plugins.unshift(new MiniCssExtractPlugin());
    config.plugins.unshift(new VanillaExtractPlugin());

    config.module.rules.unshift({
      test: /vanilla\.virtual\.css$/,
      use: [
        MiniCssExtractPlugin.loader,
        require.resolve('css-loader'),
        VanillaExtractPlugin.loader,
      ],
    });
    return config;
  },
};

module.exports = nextConfig;

@sherluok Does the fix to the next plugin from #1180 work for you?

@ha1fstack
Copy link

ha1fstack commented Oct 16, 2023

edit: fix is pending so meanwhile use appDir: true for temp solution

https://github.com/plrs9816/vanilla-extract-app-dir

Something broke again in next 13.5?

In 13.4 it works fine but the css is not generated in 13.5. (I only tested in windows)

Strangely the above demo is working, because I added unnecessary appDir: true config.
⚠ App router is available by default now, 'experimental.appDir' option can be safely removed.
It says the option does nothing, but if it's removed it doesn't work.
13.4 works fine without the option.

const nextConfig = {
  experimental: {
    appDir: true,
  },
};

@askoufis
Copy link
Contributor

@plrs9816 This should hopefully be fixed by #1193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nextjs Issue related to NextJS
Projects
None yet
Development

Successfully merging a pull request may close this issue.