
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
vite-plugin-vue-component-preview
Advanced tools
This Vite plugin support `` custom block in SFC for preview single Vue component.
This Vite plugin support <preview lang="md">
custom block in SFC for preview single Vue component.
To use this with VSCode + Volar, see https://github.com/johnsoncodehk/volar/discussions/1511
vite.config.ts
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import preview from 'vite-plugin-vue-component-preview';
export default defineConfig({
plugins: [
preview(),
vue(),
],
})
main.ts
import { createApp } from 'vue';
import App from './App.vue';
import Preview from 'vite-plugin-vue-component-preview/client';
const app = createApp(App);
app.use(Preview);
tsconfig.json
(For IDE and vue-tsc support)
{
"vueCompilerOptions": {
"plugins": ["vite-plugin-vue-component-preview/tooling"]
}
}
<!-- Component part -->
<template>
<h1>{{ msg }}</h1>
<button @click="count++">count is: {{ count }}</button>
</template>
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ msg: string }>()
const count = ref(0)
</script>
<!-- Preview part -->
<preview lang="md">
# This is preview page of HelloWorld.vue
## Props
| Props | Description |
| ----------- | -------------- |
| msg | Title message |
## Examples
<script setup>
const msgs = [
'Hello Peter',
'Hello John',
];
</script>
<template v-for="msg in msgs">
<slot :msg="msg"></slot>
</template>
<style>
body {
background-color: green;
}
</style>
</preview>
Example repo: https://github.com/johnsoncodehk/volar-starter (Open http://localhost:3000/__preview/src/components/HelloWorld.vue to see the result.)
When you want to preview the component including <slot>
, importing the component itself provides the solution as follows:
<template>
<div>
<slot></slot>
</div>
</template>
<preview lang="md">
<script setup>
import TestPreview from './TestPreview.vue' // TestPreview.vue is the name of this file itself.
const msgs = ['1', '2']
</script>
<template v-for="msg in msgs">
<TestPreview>
test {{ msg }}
</TestPreview>
</template>
</preview>
This method relates to #17.
FAQs
This Vite plugin support `` custom block in SFC for preview single Vue component.
The npm package vite-plugin-vue-component-preview receives a total of 465 weekly downloads. As such, vite-plugin-vue-component-preview popularity was classified as not popular.
We found that vite-plugin-vue-component-preview demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.