-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat(css): export preprocessCSS API #10429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me since we already export transformWithEsbuild
.
how to use this ? no documentation ? |
How do we use this feature? |
Is there no documentation for this? Took me a while to end up at #8687. I’m happy to see this is implemented though… how do I use it? 😄 |
Hmm, this usage in https://github.com/withastro/astro/blob/97f876abba31438ae4cc41fdbae276fbbc78e98b/packages/astro/src/core/compile/style.ts#L21 seems pretty low level. I’m assuming @GrayYoung was looking for a method of telling Vite to compile separate Or (maybe better) does anyone know of alternative plugins available yet for Vite which can accomplish this? Just seems to make sense to me that this should be available to configure in this location (if not officially by Vite itself of course, then hopefully via a simple dedicated plugin). Edit: Then again, maybe I’m being old fashioned 😅. Vite focuses primarily on intercepting and transforming for dev (I’m coming from ancient world of gulp/grunt). Seems Vite might already do something like this using something akin to |
Starting a discussion to gather feedback so we can move this feature out of experimental: |
@patricknelson I have a similar problem, I need to use plain |
FWIW @PedroAugustoRamalhoDuarte, over the past year or so, I've found plain scripts in It helps to also have a design pattern to include e.g. (untested, but simple enough to get the idea) {
"scripts": {
"build": "npm run build:vite && npm run build:sass",
"build:vite": "vite build",
"build:sass": "npx sass ...",
"dev": "concurrently --kill-others 'npm run dev:vite' 'npm run dev:sass'",
"dev:vite": "vite",
"dev:sass": "npx sass --watch ...",
}
} |
Description
Export
preprocessCSS()
, which is callingcompileCSS()
without theurlReplacer
function.The
urlReplacer
is not ran as it uses thethis
context of Rollup, and it isn't necessary as the preprocessed CSS can run through Vite's pipeline to get it's URL replaced later.This is helpful for template compilers like Svelte and Astro that can only parse pure CSS, so style tags need to be preprocessed.
Additional context
I'm currently testing this API in:
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).