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

build.cssCodeSplit: false => CSS missing in dist/manifest.json #6477

Closed
7 tasks done
brillout opened this issue Jan 12, 2022 · 4 comments
Closed
7 tasks done

build.cssCodeSplit: false => CSS missing in dist/manifest.json #6477

brillout opened this issue Jan 12, 2022 · 4 comments

Comments

@brillout
Copy link
Contributor

brillout commented Jan 12, 2022

Describe the bug

When setting build.cssCodeSplit: false then the CSS is missing in the dist/manifest.json (dist/client/manifest.json if using vite-plugin-ssr).

Reproduction

https://github.com/brillout/vite-plugin-ssr-disabled-css-codesplit/tree/main

System Info

System:
    OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (2) x64 06/7a
    Memory: 2.71 GB / 2.71 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 16.5.0 - ~/.config/nvm/versions/node/v16.5.0/bin/node
    Yarn: 1.22.11 - ~/.config/nvm/versions/node/v16.5.0/bin/yarn
    npm: 7.20.5 - ~/.config/nvm/versions/node/v16.5.0/bin/npm
    Watchman: 4.9.0 - /home/romuuu/.nix-profile/bin/watchman
  Browsers:
    Firefox: 83.0
  npmPackages:
    @vitejs/plugin-vue: ^2.0.1 => 2.0.1 
    vite: ^2.7.2 => 2.7.10 

Used Package Manager

yarn

Logs

No response

Validations

@Mcdostone
Copy link

Mcdostone commented Jan 13, 2022

Same issue with the following vite configuration https://stackblitz.com/edit/vite-dkc1an?file=vite.config.js

// vite.config.js
import { defineConfig } from 'vite'
import path from 'path'

export default defineConfig(() => {
    return {
      root: '.',
      build: {
        outDir: './dist',
        manifest: true,
        cssCodeSplit: false,
        rollupOptions: {
          input: {
            'css/style.css': path.resolve('./style.css'),
          },
        },
      },
    }
})
npm run build

> vite-project@0.0.0 build
> vite build

vite v2.7.10 building for production...
✓ 1 modules transformed.
dist/manifest.json                      0.11 KiB
dist/assets/css/style.css.1b65f072.js   0.00 KiB / gzip: 0.02 KiB  # does it make any sense?
dist/assets/style.0cc4c6eb.css          0.17 KiB / gzip: 0.14 KiB     # output path is wrong, I would expect dist/assets/css/style.0cc4c6eb.css
{
  "style.css": {
    "file": "assets/css/style.css.1b65f072.js", // I would expect a CSS file, not JS 
    "src": "style.css",
    "isEntry": true
  }
}

@davidwebca
Copy link

Was this ever solved? I'm currently facing the same issue, I'm unable to get my CSS file to bundle into one file instead of multiple... 🤔

@laurentvd
Copy link

laurentvd commented Mar 10, 2022

No, but I made a workaround. I'm building my frontend using yarn run build. Yarn then automatically triggers the postbuild command:

"postbuild": "yarn run write-style-path-to-manifest",
"write-style-path-to-manifest": "sed -e '$ d' ../public/build/manifest.json > ../public/build/manifest-temp.json && echo ',\"styles.css\": \"'$(cd ../public/build && ls assets/*.css)'\"}' >> ../public/build/manifest-temp.json && mv -f ../public/build/manifest-temp.json ../public/build/manifest.json",

Basically, it replaces the last line of my manifest file with the path to the only css file in assets.

@sapphi-red
Copy link
Member

Fixed in #6649

@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants