Skip to content

Add support for appending a single css file outside#37

Closed
tarjei wants to merge 1 commit intonvh95:mainfrom
tarjei:css-tailwind-support
Closed

Add support for appending a single css file outside#37
tarjei wants to merge 1 commit intonvh95:mainfrom
tarjei:css-tailwind-support

Conversation

@tarjei
Copy link
Copy Markdown

@tarjei tarjei commented Jan 8, 2025

Summary/ Motivation (TLDR;)

I want to load a single css file that is generated outside of the testrun.

This pr adds a --css=file option that copies in the file when starting the testserver.

Related issues

Features

  • Adds the --css=/path/to/file.css option when starting vitest-preview.

Fixes

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 8, 2025

Deploy Preview for vitest-preview canceled.

Name Link
🔨 Latest commit 4b30552
🔍 Latest deploy log https://app.netlify.com/sites/vitest-preview/deploys/677e6a2eb3d5640008882ecc

@matheusslg
Copy link
Copy Markdown

@tarjei are you planning to merge and release this? I had to fork your project because of that

@tarjei
Copy link
Copy Markdown
Author

tarjei commented Apr 16, 2025

@matheusslg I'm waiting for @nvh95 to take this further. I would have merged it if I could :)

@nvh95
Copy link
Copy Markdown
Owner

nvh95 commented Sep 21, 2025

Hi @tarjei. Thank you very much for your efforts in helping with this.

After some consideration, I think it's better to configure externalCss using a configure utility. Something like this

// setup.ts or setup.js
import { configure } from 'vitest-preview';

configure({
  externalCss: [
    './styles/global.css',
    './public/index.css',
    './node_modules/@your-ui-lib/dist/styles.css',
  ],
});

I handled it in #48, along with some other related changes.

It is documented here: https://www.vitest-preview.com/guide/api/configure

I also published version v0.0.2-alpha.1 which includes this change. v0.0.2 will be out very soon after some testing.

Thank you again 🫶

@nvh95
Copy link
Copy Markdown
Owner

nvh95 commented Sep 22, 2025

@all-contributors please add @tarjei for idea

@allcontributors
Copy link
Copy Markdown
Contributor

@nvh95

I've put up a pull request to add @tarjei! 🎉

@tarjei
Copy link
Copy Markdown
Author

tarjei commented Sep 22, 2025

I think your solution is even better @nvh95 ! Good job.

@tarjei tarjei closed this Sep 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants