vite-plugin-vue icon indicating copy to clipboard operation
vite-plugin-vue copied to clipboard

Export some helper functions to make plugin creators get block's import request id easierly

Open kainstar opened this issue 1 year ago • 1 comments

Related plugins

Description

I am developing a plugin to enable SFC's style to work in shadow DOM. My idea is to modify the SFC script block, import the style contents, and insert them into the shadow root at runtime. The problem is how to correctly write the source path for style imports.

The only solution I have thought of is copying code from plugin-vue to ensure that the logic matches that of the official version. However, this would require me to constantly synchronize with any changes made by the official version. It could also result in differences between my plugin's logic and that of the official version if users install an incompatible combination of plugin-vue and my plugin.

Therefore, I am wondering if it is possible to export some helper functions for plugin creators, which would allow us to easily write import request ids for blocks.

Suggested solution

For instance, a function that get the request id of a style block like:

function getStyleRequestId(descriptor: SFCDescriptor, index: number): string

Alternative

No response

Additional context

No response

Validations

kainstar avatar Dec 28 '23 16:12 kainstar

My use case: I would like to import the style block from the script tag in the same vue file, and then, that css should not go to the vite css flow that end in a css file.

import css from thisfile.vue?style (so that I can perform custom inject)

davidglezz avatar Jun 07 '25 18:06 davidglezz