{"id":16365214,"url":"https://github.com/xiaoluoboding/vue-sfc-sandbox","last_synced_at":"2026-02-12T10:30:17.543Z","repository":{"id":50101334,"uuid":"355544930","full_name":"xiaoluoboding/vue-sfc-sandbox","owner":"xiaoluoboding","description":"Vue SFC Sandbox, Sandbox as a Vue 3 component.","archived":false,"fork":false,"pushed_at":"2021-06-07T04:45:24.000Z","size":5054,"stargazers_count":43,"open_issues_count":5,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-02T02:05:10.308Z","etag":null,"topics":["codesandbox","demonstration","sandbox","sfc","vue3"],"latest_commit_sha":null,"homepage":"https://vue-sfc-sandbox.vercel.app/","language":"Vue","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/xiaoluoboding.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["xiaoluoboding"]}},"created_at":"2021-04-07T12:56:06.000Z","updated_at":"2024-10-14T00:09:18.000Z","dependencies_parsed_at":"2022-08-31T05:10:35.015Z","dependency_job_id":null,"html_url":"https://github.com/xiaoluoboding/vue-sfc-sandbox","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoluoboding%2Fvue-sfc-sandbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoluoboding%2Fvue-sfc-sandbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoluoboding%2Fvue-sfc-sandbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaoluoboding%2Fvue-sfc-sandbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaoluoboding","download_url":"https://codeload.github.com/xiaoluoboding/vue-sfc-sandbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239809568,"owners_count":19700643,"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":["codesandbox","demonstration","sandbox","sfc","vue3"],"created_at":"2024-10-11T02:42:58.550Z","updated_at":"2026-02-12T10:30:17.485Z","avatar_url":"https://github.com/xiaoluoboding.png","language":"Vue","funding_links":["https://github.com/sponsors/xiaoluoboding"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eVue SFC Sandbox\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cp align=\"center\"\u003e\n  Vue SFC Sandbox, Sandbox as a Vue 3 component.\n\u003c/p\u003e\n\n\u003cbr\u003e\n\n[![NPM][npmBadge]][npmUrl]\n[![NPM Download][npmDtBadge]][npmDtUrl]\n[![License][licenseBadge]][licenseUrl]\n\n[npmBadge]:https://img.shields.io/npm/v/vue-sfc-sandbox.svg?maxAge=2592000\n[npmUrl]:https://www.npmjs.com/package/vue-sfc-sandbox\n\n[npmDtBadge]:https://img.shields.io/npm/dt/vue-sfc-sandbox.svg\n[npmDtUrl]:https://www.npmjs.com/package/vue-sfc-sandbox\n\n[licenseBadge]:https://img.shields.io/badge/license-MIT-blue.svg\n[licenseUrl]:https://raw.githubusercontent.com/vueblocks/vue-sfc-sandbox/master/LICENSE\n\n\u003c/div\u003e\n\n## 🖼️ Preview\n\n![preview](./preview.gif)\n\n## ✨ Features\n\n### 🗳️ Sandbox\n\n* 💪 Fully Typed\n* 📁 Virtual File System (Support Compile `.vue/.js` File). based on [vue-sfc2esm](https://github.com/xiaoluoboding/vue-sfc2esm)\n* 👬 Friendly Error Tips. based on [vue-sfc2esm](https://github.com/xiaoluoboding/vue-sfc2esm)\n* 🧪 Transpiled SFC File to ES Modules.\n* 🔌 Support Externals CDN, like [unpkg](https://unpkg.com/)、[jsdelivr](https://www.jsdelivr.com/) etc.\n* 🧩 Load [Import Maps](https://github.com/WICG/import-maps) as ES Modules.\n* 💨 Built-in Compile `windicss` on the fly, also support `attributify` mode.\n\n### ✏️ Editor Panel\n\n* 🎨 Themeable Editor based on [Monaco Editor](https://github.com/microsoft/monaco-editor)\n* 🧑‍💻 Developer Friendly, built-in `Vue 3` intellisense support\n* ↕️ REPL Sandbox with Split Panes, Split `\u003ctemplate\u003e` \u0026 `\u003cscript\u003e` tag\n\n### 👓 Preview Panel\n\n* ⚡️ Runtime Compile SFC File\n* 🔍 Fullscreen View\n* 🌛 Darkmode\n\n## 💡 Inspiration\n\nThis project is heavily inspired by [Vue SFC Playground](https://github.com/vuejs/vue-next/tree/master/packages/sfc-playground). Actually Copied from it.\n\n## 📦 Installation\n\n```bash\nyarn add vue-sfc-sandbox -S\nor\nnpm i vue-sfc-sandbox -S\n```\n\n## 📖 Usage\n\n\u003e Notice that `vue-sfc-sandbox` is depending on `@vue/compiler-sfc`, and `@vue/compiler-sfc` depending on `Consolidate` packages.\n\u003e We need configure `Consolidate` as externals in `vue.config.js` or `vite.config.ts` file.\n\n### Demos\n\nVue 3 Demo: [Vue CLI 3.x](./examples/vue3-demo/README.md) | Vite 2 Demo: [@vitejs/app](./examples/vite2-demo/README.md)\n\n### Configure Vue 3\n\nAdd this config in [vue.config.js](./examples/vue3-demo/vue.config.js) file.\n\n```ts\n// vue.config.js in vue 3 project\nmodule.exports = {\n  ...\n  configureWebpack: {\n    externals: {\n      consolidate: 'Consolidate'\n    }\n  }\n  ...\n}\n```\n\n### Configure Vite 2\n\nAdd this config in [vite.config.ts](./examples/vite2-demo/vite.config.ts) file.\n\n```ts\nimport { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\n\n// https://vitejs.dev/config/\nexport default defineConfig({\n  define: {\n    'process.env': {}\n  },\n  plugins: [vue()],\n  optimizeDeps: {\n    exclude: ['consolidate', 'velocityjs', 'dustjs-linkedin', 'atpl', 'liquor', 'twig', 'ejs', 'eco', 'jazz', 'hamljs', 'hamlet', 'jqtpl', 'whiskers', 'haml-coffee', 'hogan.js', 'templayed', 'handlebars', 'underscore', 'lodash', 'walrus', 'mustache', 'just', 'ect', 'mote', 'toffee', 'dot', 'bracket-template', 'ractive', 'htmling', 'babel-core', 'plates', 'react-dom/server', 'react', 'vash', 'slm', 'marko', 'teacup/lib/express', 'coffee-script', 'squirrelly', 'twing']\n  }\n})\n```\n\n### Setup SFC Sandbox Component\n\n```ts\n// main.ts\nimport { createApp } from 'vue'\nimport App from './App.vue'\n\nimport VueSfcSandbox from 'vue-sfc-sandbox'\n\ncreateApp(App)\n  .use(VueSfcSandbox)\n  .mount('#app')\n```\n\n### Use SFC Sandbox Component\n\n```html\n\u003ctemplate\u003e\n  \u003c!-- [ESM] default case with \u003cscript setup\u003e --\u003e\n  \u003csfc-sandbox v-bind=\"defaultAttrs\" /\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"ts\"\u003e\nimport { defineComponent } from 'vue'\n\nexport default defineComponent({\n  name: 'HelloWorld',\n\n  setup () {\n    const defaultAttrs = {\n      scriptSetup: true,\n      height: 200,\n      sfcFilename: 'DefaultDemo.vue',\n      sfcCode: `\n        \u003ctemplate\u003e\n          \u003ch1\u003e{{ msg }}\u003c/h1\u003e\n        \u003c/template\u003e\n\n        \u003cscript setup\u003e\n        const msg = 'Hello World!'\n        \u003c/script\u003e\n      `\n    }\n\n    return {\n      defaultAttrs\n    }\n  }\n})\n\u003c/script\u003e\n```\n\n## Props\n\n| Attribute | Description | Type | Accepted values | Default |\n|:--------:|--------|--------|:--------:|:--------:|\n| height | the sandbox height unit (px) | Number | - | 400 |\n| import-maps | specify a import maps in the `\u003cscript\u003e` element include `type=\\\"importmap\\\"` | String | - | - |\n| externals | specify some cdn like jsdelivr、unpkg | String | - | - |\n| sfc-filename | virtual sfc filename like `HelloWorld.vue` | - | - |\n| sfc-code | transpile sfc code to es modules by `vue-sfc2esm` | String | - | - |\n| script-setup | whether script editor using `\u003cscript setup\u003e` proposal | Boolean | `true`/`false` | `false` |\n\n## 💻 Development\n\n```bash\nyarn install\n```\n\n### Compiles and hot-reloads for development\n\n```bash\nyarn serve\n```\n\n### Compiles and minifies for production\n\n```bash\nyarn build\n```\n\n### Lints and fixes files\n\n```bash\nyarn lint\n```\n\n## 🗃️ Similar Repos\n\n* [vuep](https://github.com/QingWei-Li/vuep) - 🎡 A component for rendering Vue components with live editor and preview.\n* [codepan](https://github.com/egoist/codepan) - Like codepen and jsbin but works offline.\n* [demosify](https://github.com/demosify/demosify) - Create a playground to show the demos of your projects.\n\n## 📄 License\n\nMIT [@xiaoluoboding](https://github.com/xiaoluoboding)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoluoboding%2Fvue-sfc-sandbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaoluoboding%2Fvue-sfc-sandbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaoluoboding%2Fvue-sfc-sandbox/lists"}