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

:sparkles: add option to inline/load css to style element for esbuild plugin

Open salamaashoush opened this issue 1 year ago • 7 comments

In some environments and use cases (eg Figma plugins) you can't load external resources with relative paths so you either have to host CSS separately on a remote server or inline it in the JS/HTML so this PR adds a new option useStyleLoader to @vanilla-extract/esbuild-plugin that allows you to skip CSS loader and inject the CSS using style element in the current document, by emitting a JS file with the code to do that similar to (style-loader)

salamaashoush avatar Jul 25 '23 11:07 salamaashoush

⚠️ No Changeset found

Latest commit: 3beb1a3c0376b2a43b8a7658c6c94ceb90aa67ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

changeset-bot[bot] avatar Jul 25 '23 11:07 changeset-bot[bot]

I'm not sure this should be an option of VE, it's a very specific use case. Isn't it possible to configure esbuild (maybe with a plugin) so that it transforms the css loader result into this kind of style loader?

graup avatar Jul 26 '23 06:07 graup

I'm not sure this should be an option of VE, it's a very specific use case. Isn't it possible to configure esbuild (maybe with a plugin) so that it transforms the css loader result into this kind of style loader?

@graup I tried to get it working as a separate plugin but it didn't work, I either have to create the VE plugin again or add the support to the existing one, I think it could be because VE css files are virtual and they got intercepted first by vanilla-extract and handed to the css loader directly which I can't intercept

salamaashoush avatar Jul 26 '23 08:07 salamaashoush

Can you release a version. thk

yaojiu19 avatar Dec 05 '23 07:12 yaojiu19

Can you release a version. thk

@yaojiu19 I'm not sure if this PR is ready to test, or is even something we want to still pursue.

@salamaashoush Any updates?

askoufis avatar Dec 06 '23 23:12 askoufis

I can rebase and update the MR if you want to test and merge it, currently i copied the plugin into my project repository and using it

salamaashoush avatar Dec 07 '23 08:12 salamaashoush

I can rebase and update the MR if you want to test and merge it, currently i copied the plugin into my project repository and using it

yeah, manually import css files is inconvenient in monorepo‘s project

yaojiu19 avatar Dec 11 '23 06:12 yaojiu19