Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@unplugin-vue-ce/sub-style
Advanced tools
A vue plugin that extends vue's Custom Element capabilities (sub component style)
The implementation principle of @unplugin-vue-ce/sub-style
comes from vue/core pr #7942
Tips: ⚠ This plugin will inject the implementation code into the vue runtime, which is what I have to tell you. If you have any problems using it, please submit an issue
npm i @unplugin-vue-ce/sub-style
or
yarn add @unplugin-vue-ce/sub-style
or
pnpm add @unplugin-vue-ce/sub-style
Tips: You need to enable the
customElement
option of@vitejs/plugin-vue
// vite.config.ts
import { defineConfig } from 'vite'
import { viteVueCESubStyle } from '@unplugin-vue-ce/sub-style'
import vue from '@vitejs/plugin-vue'
import type { PluginOption } from 'vite'
export default defineConfig({
plugins: [
vue(),
viteVueCESubStyle() as PluginOption,
],
})
// rollup.config.js
import { rollupVueCESubStyle } from '@unplugin-vue-ce/sub-style'
export default {
plugins: [
rollupVueCESubStyle(),
],
}
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require('@unplugin-vue-ce/sub-style').webpackVueCESubStyle(),
],
}
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
require('@unplugin-vue-ce/sub-style').webpackVueCESubStyle({}),
],
},
}
// esbuild.config.js
import { build } from 'esbuild'
import { esbuildVueCESubStyle } from '@unplugin-vue-ce/sub-style'
build({
plugins: [esbuildVueCESubStyle()],
})
via: https://github.com/unplugin/unplugin-vue-ce/issues/118
@unplugin-vue-ce/sub-style
Starting from version "1.0.0-beta.19", a new option isESCSS
is added, which is turned off by default.
This is an experimental feature.
// vite.config.ts
import { defineConfig } from 'vite'
import { viteVueCESubStyle } from '@unplugin-vue-ce/sub-style'
import vue from '@vitejs/plugin-vue'
import type { PluginOption } from 'vite'
export default defineConfig({
plugins: [
vue(),
viteVueCESubStyle({
isESCSS: true,
}) as PluginOption,
],
})
When isESCSS
is turned on,@unplugin-vue-ce/sub-style
will automatically move the css import part of the script block to the style block,
so that vue-plugin can compile its style. If you do not do this , it will be injected into the head of the document as a global style.
<template>
<div>
foo
</div>
</template>
<script setup>
import './test.css'
</script>
transform result
<template>
<div>
foo
</div>
</template>
<script setup>
</script>
<style lang="css">
@import './test.css';
</style>
Since vue enables shadow dom by default, it will isolate the style, so you need to add the root component of each web component to add the reference style:
<!-- xxx.vue -->
<style>
@tailwind base;
@tailwind components;
@tailwind utilities;
</style>
or (only vite)
<!-- xxx.vue -->
<script>
import '@virtual:taiwind'
</script>
Only postcss plugins are supported (via: https://unocss.dev/integrations/postcss#install),
you need to add the root component of each web component to add the reference style:
<!-- xxx.vue -->
<style>
@unocss preflights;
@unocss default;
@unocss;
</style>
or (only vite)
<!-- xxx.vue -->
<script>
import '@virtual:uno'
</script>
Windi css is not supported Windi CSS is Sunsetting
FAQs
A vue plugin that extends vue's Custom Element capabilities (sub component style)
The npm package @unplugin-vue-ce/sub-style receives a total of 1,678 weekly downloads. As such, @unplugin-vue-ce/sub-style popularity was classified as popular.
We found that @unplugin-vue-ce/sub-style demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.