workflow(sfc-playground): support import map

This commit is contained in:
Evan You
2021-03-31 13:31:00 -04:00
parent e097bd4dd5
commit 5ee7e6bc70
9 changed files with 348 additions and 261 deletions

View File

@@ -20,7 +20,7 @@ const onChange = debounce((code: string) => {
const activeCode = ref(store.activeFile.code)
const activeMode = computed(
() => (store.activeFilename.endsWith('.js') ? 'javascript' : 'htmlmixed')
() => (store.activeFilename.endsWith('.vue') ? 'htmlmixed' : 'javascript')
)
watch(

View File

@@ -45,8 +45,12 @@ function focus({ el }: VNode) {
function doneAddFile() {
const filename = pendingFilename.value
if (!filename.endsWith('.vue') && !filename.endsWith('.js')) {
store.errors = [`Playground only supports .vue or .js files.`]
if (
!filename.endsWith('.vue') &&
!filename.endsWith('.js') &&
filename !== 'import-map.json'
) {
store.errors = [`Playground only supports *.vue, *.js files or import-map.json.`]
return
}