- πͺ Fully Typed
- π Virtual File System (Support Compile
.vue/.js
File). based on vue-sfc2esm - π¬ Friendly Error Tips. based on vue-sfc2esm
- π§ͺ Transpiled SFC File to ES Modules.
- π Support Externals CDN, like unpkgγjsdelivr etc.
- 𧩠Load Import Maps as ES Modules.
- π¨ Built-in Compile
windicss
on the fly, also supportattributify
mode.
- π¨ Themeable Editor based on Monaco Editor
- π§βπ» Developer Friendly, built-in
Vue 3
intellisense support βοΈ REPL Sandbox with Split Panes, Split<template>
&<script>
tag
- β‘οΈ Runtime Compile SFC File
- π Fullscreen View
- π Darkmode
This project is heavily inspired by Vue SFC Playground. Actually Copied from it.
yarn add vue-sfc-sandbox -S
or
npm i vue-sfc-sandbox -S
Notice that
vue-sfc-sandbox
is depending on@vue/compiler-sfc
, and@vue/compiler-sfc
depending onConsolidate
packages. We need configureConsolidate
as externals invue.config.js
orvite.config.ts
file.
Vue 3 Demo: Vue CLI 3.x | Vite 2 Demo: @vitejs/app
Add this config in vue.config.js file.
// vue.config.js in vue 3 project
module.exports = {
...
configureWebpack: {
externals: {
consolidate: 'Consolidate'
}
}
...
}
Add this config in vite.config.ts file.
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
define: {
'process.env': {}
},
plugins: [vue()],
optimizeDeps: {
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']
}
})
// main.ts
import { createApp } from 'vue'
import App from './App.vue'
import VueSfcSandbox from 'vue-sfc-sandbox'
createApp(App)
.use(VueSfcSandbox)
.mount('#app')
<template>
<!-- [ESM] default case with <script setup> -->
<sfc-sandbox v-bind="defaultAttrs" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
name: 'HelloWorld',
setup () {
const defaultAttrs = {
scriptSetup: true,
height: 200,
sfcFilename: 'DefaultDemo.vue',
sfcCode: `
<template>
<h1>{{ msg }}</h1>
</template>
<script setup>
const msg = 'Hello World!'
</script>
`
}
return {
defaultAttrs
}
}
})
</script>
Attribute | Description | Type | Accepted values | Default |
---|---|---|---|---|
height | the sandbox height unit (px) | Number | - | 400 |
import-maps | specify a import maps in the <script> element include type=\"importmap\" |
String | - | - |
externals | specify some cdn like jsdelivrγunpkg | String | - | - |
sfc-filename | virtual sfc filename like HelloWorld.vue |
- | - | |
sfc-code | transpile sfc code to es modules by vue-sfc2esm |
String | - | - |
script-setup | whether script editor using <script setup> proposal |
Boolean | true /false |
false |
yarn install
yarn serve
yarn build
yarn lint
- vuep - π‘ A component for rendering Vue components with live editor and preview.
- codepan - Like codepen and jsbin but works offline.
- demosify - Create a playground to show the demos of your projects.
MIT @xiaoluoboding