vanilla-extract icon indicating copy to clipboard operation
vanilla-extract copied to clipboard

vite: allow passing overrides for vite config

Open XiNiHa opened this issue 1 year ago • 5 comments

Adds viteConfigOverrides option to the Vite plugin. This option works as an escape hatch for users to deal with incompatibilities between their config and the VE Vite plugin.

XiNiHa avatar Jul 07 '24 15:07 XiNiHa

🦋 Changeset detected

Latest commit: a7c1cc0dbdbc0159c46dfe8d358be5649ababa7b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@vanilla-extract/vite-plugin Minor
@vanilla-extract-private/test-helpers Patch
@vanilla-extract-private/tests Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Jul 07 '24 15:07 changeset-bot[bot]

I'd like to understand what problem this is actually solving for you before considering whether this feature should be added. The vite plugin already loads your existing vite config when creating the compiler - see here - so anything you want to override could instead just be done in your own vite config, instead of by the plugin.

askoufis avatar Jul 12 '24 03:07 askoufis

I want to actually "override" the config so have a separate config for running VE transforms, not just inheriting the primary config.

My usecase is kinda tricky. The Solid Vite plugin emits browser-only code if it's not an SSR build, which breaks VE evaluator to break. However since VE Vite plugin just takes my Vite config and runs transform with it, it's impossible to prevent Solid Vite plugin from emitting those code.

While this specific usecase can be fixed by filtering out the Solid Vite plugin (like what we're already doing with the Remix plugin) issues like this will always come up as the target environment between Vite and VE Vite plugin will be always different (unless it's a SSR build) Therefore having an escape hatch will be valuable enough to let users workaround their issues.

XiNiHa avatar Jul 12 '24 04:07 XiNiHa

@XiNiHa did you found a solution to get solid work with vanilla extract?

riccardoperra avatar Oct 26 '24 06:10 riccardoperra

@XiNiHa did you found a solution to get solid work with vanilla extract?

I just yarn patched it 😅

https://github.com/contentstech-com/stackflow/blob/feat%2Fsolid-integration/.yarn%2Fpatches%2F%40vanilla-extract-vite-plugin-npm-4.0.12-ed14a9ba3b.patch

XiNiHa avatar Oct 26 '24 06:10 XiNiHa