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

[Vite CSS] css not loaded when build.cssCodeSplit: true and build.modulePreload: false #12273

Closed
7 tasks done
AngusFu opened this issue Mar 3, 2023 · 2 comments
Closed
7 tasks done
Labels
duplicate This issue or pull request already exists

Comments

@AngusFu
Copy link
Contributor

AngusFu commented Mar 3, 2023

Describe the bug

According to the vite official site, when build.cssCodeSplit is "enabled, CSS imported in async chunks will be inlined into the async chunk itself and inserted when the chunk is loaded".

image

Throughout the whole site, I just can't find any relation between build.modulePreload and build.cssCodeSplit.

However, when build.modulePreload: false and build.cssCodeSplit: true are set, I find that the async css chunk is not "inlined into the async chunk itself", let alone loaded.

BTW, with the command grep -nr ${HASH_OF_CSS_CHUNK} ./dist I found no match in those generated assets.

image

image

image

image

My vite config is:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  build: {
    minify: false,
    cssCodeSplit: true,
    modulePreload: false,
  },
});

Reproduction

https://stackblitz.com/edit/vitejs-vite-qz7uvm?file=vite.config.js

Steps to reproduce

Open stackblitz.com and just run npm run build in the command line.

System Info

vite/4.1.4 linux-x64 node-v16.14.2

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Mar 3, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@AngusFu AngusFu changed the title css not loaded in build mode when buildcssCodeSplit is true and build.modulePreload is false css not loaded in build mode when build.cssCodeSplit is true and build.modulePreload is false Mar 3, 2023
@AngusFu AngusFu changed the title css not loaded in build mode when build.cssCodeSplit is true and build.modulePreload is false [Vite CSS] css not loaded when build.cssCodeSplit: true and build.modulePreload: false Mar 3, 2023
@fi3ework
Copy link
Member

fi3ework commented Mar 4, 2023

duplicated with #10773

@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels Mar 6, 2023
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants