{"id":13678731,"url":"https://github.com/johnsoncodehk/vite-plugin-vue-component-preview","last_synced_at":"2025-04-06T10:14:40.339Z","repository":{"id":37417475,"uuid":"504861650","full_name":"johnsoncodehk/vite-plugin-vue-component-preview","owner":"johnsoncodehk","description":"Vite plugin for preview Vue component","archived":false,"fork":false,"pushed_at":"2024-06-29T23:03:12.000Z","size":74,"stargazers_count":130,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T09:07:07.644Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/vite-plugin-vue-component-preview","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnsoncodehk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-18T14:12:26.000Z","updated_at":"2025-03-14T20:25:49.000Z","dependencies_parsed_at":"2024-06-18T15:32:33.808Z","dependency_job_id":"d747f5b0-c187-4962-b880-1cbf2fab3b59","html_url":"https://github.com/johnsoncodehk/vite-plugin-vue-component-preview","commit_stats":{"total_commits":71,"total_committers":3,"mean_commits":"23.666666666666668","dds":0.04225352112676062,"last_synced_commit":"71ff67d3f91b9ff1cc76a0c94dadfad95d88ac6a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsoncodehk%2Fvite-plugin-vue-component-preview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsoncodehk%2Fvite-plugin-vue-component-preview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsoncodehk%2Fvite-plugin-vue-component-preview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnsoncodehk%2Fvite-plugin-vue-component-preview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnsoncodehk","download_url":"https://codeload.github.com/johnsoncodehk/vite-plugin-vue-component-preview/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464226,"owners_count":20942970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T13:00:57.585Z","updated_at":"2025-04-06T10:14:40.315Z","avatar_url":"https://github.com/johnsoncodehk.png","language":"TypeScript","readme":"# vite-plugin-vue-component-preview\n\nThis Vite plugin support `\u003cpreview lang=\"md\"\u003e` custom block in SFC for preview single Vue component.\n\nTo use this with VSCode + Volar, see https://github.com/johnsoncodehk/volar/discussions/1511\n\n## Setup\n\n`vite.config.ts`\n\n```ts\nimport { defineConfig } from 'vite';\nimport vue from '@vitejs/plugin-vue';\nimport preview from 'vite-plugin-vue-component-preview';\n\nexport default defineConfig({\n\tplugins: [\n\t\tpreview(),\n\t\tvue(),\n\t],\n})\n```\n\n`main.ts`\n\n```ts\nimport { createApp } from 'vue';\nimport App from './App.vue';\nimport Preview from 'vite-plugin-vue-component-preview/client';\n\nconst app = createApp(App);\napp.use(Preview);\n```\n\n`tsconfig.json` (For IDE and vue-tsc support)\n\n```json\n{\n  \"vueCompilerOptions\": {\n    \"plugins\": [\"vite-plugin-vue-component-preview/tooling\"]\n  }\n}\n```\n\n## Example\n\n```html\n\u003c!-- Component part --\u003e\n\u003ctemplate\u003e\n\t\u003ch1\u003e{{ msg }}\u003c/h1\u003e\n\t\u003cbutton @click=\"count++\"\u003ecount is: {{ count }}\u003c/button\u003e\n\u003c/template\u003e\n\n\u003cscript setup lang=\"ts\"\u003e\nimport { ref } from 'vue'\n\ndefineProps\u003c{ msg: string }\u003e()\n\nconst count = ref(0)\n\u003c/script\u003e\n\n\u003c!-- Preview part --\u003e\n\n\u003cpreview lang=\"md\"\u003e\n\n\t# This is preview page of HelloWorld.vue\n\n\t## Props\n\n\t| Props       | Description    |\n\t| ----------- | -------------- |\n\t| msg         | Title message  |\n\n\t## Examples\n\n\t\u003cscript setup\u003e\n\tconst msgs = [\n\t'Hello Peter',\n\t'Hello John',\n\t];\n\t\u003c/script\u003e\n\n\t\u003ctemplate v-for=\"msg in msgs\"\u003e\n\t\t\u003cslot :msg=\"msg\"\u003e\u003c/slot\u003e\n\t\u003c/template\u003e\n\n\t\u003cstyle\u003e\n\tbody {\n\t\tbackground-color: green;\n\t}\n\t\u003c/style\u003e\n\n\u003c/preview\u003e\n```\n\nExample repo: https://github.com/johnsoncodehk/volar-starter (Open http://localhost:3000/__preview/src/components/HelloWorld.vue to see the result.)\n\n### Self-import\n\nWhen you want to preview the component including `\u003cslot\u003e`, importing the component itself provides the solution as follows:\n\n```html\n\u003ctemplate\u003e\n\t\u003cdiv\u003e\n\t\t\u003cslot\u003e\u003c/slot\u003e\n\t\u003c/div\u003e\n\u003c/template\u003e\n\n\u003cpreview lang=\"md\"\u003e\n\n\t\u003cscript setup\u003e\n\timport TestPreview from './TestPreview.vue'\t// TestPreview.vue is the name of this file itself.\n\tconst msgs = ['1', '2']\n\t\u003c/script\u003e\n\n\t\u003ctemplate v-for=\"msg in msgs\"\u003e\n\t\t\u003cTestPreview\u003e\n\t\t\ttest {{ msg }}\n\t\t\u003c/TestPreview\u003e\n\t\u003c/template\u003e\n\n\u003c/preview\u003e\n```\n\nThis method relates to [#17](https://github.com/johnsoncodehk/vite-plugin-vue-component-preview/issues/17).\n\n## Sponsors\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://cdn.jsdelivr.net/gh/johnsoncodehk/sponsors/sponsors.svg\"\u003e\n\t\t\u003cimg src=\"https://cdn.jsdelivr.net/gh/johnsoncodehk/sponsors/sponsors.svg\"/\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n## Credits\n\n- Markdown parser power by https://github.com/antfu/vite-plugin-vue-markdown\n","funding_links":[],"categories":["TypeScript","Pre-packed"],"sub_categories":["Plugins"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsoncodehk%2Fvite-plugin-vue-component-preview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnsoncodehk%2Fvite-plugin-vue-component-preview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnsoncodehk%2Fvite-plugin-vue-component-preview/lists"}