Remove svg support in Playground

This commit is contained in:
2024-01-12 18:11:02 +08:00
parent ed4cef1c78
commit dc4e49343b
8 changed files with 33 additions and 47 deletions

View File

@@ -1,9 +1,9 @@
import esbuild, { Loader, OnLoadArgs, Plugin, PluginBuild } from 'esbuild-wasm'
import { IFiles, IImportMap } from '@/components/Playground/shared.ts'
import { cssToJs, ENTRY_FILE_NAME, jsonToJs } from '@/components/Playground/files.ts'
import localforage from 'localforage'
import axios from 'axios'
import { addReactImport } from '@/components/Playground/utils.ts'
import { IFiles, IImportMap } from '@/components/Playground/shared'
import { cssToJs, ENTRY_FILE_NAME, jsonToJs } from '@/components/Playground/files'
import { addReactImport } from '@/components/Playground/utils'
class Compiler {
private init = false
@@ -108,6 +108,9 @@ class Compiler {
path: `${args.path.substring(2)}.js`
}
}
if (/\.\/.*\.css/.test(args.path) && !args.resolveDir) {
throw Error(`Css '${args.path}' not found`)
}
if (/^https?:\/\/.*/.test(args.path)) {
return {
@@ -155,14 +158,6 @@ class Compiler {
}
})
build.onLoad({ filter: /.*\.svg$/ }, async (args: OnLoadArgs) => {
const contents = files[args.path].value
return {
loader: 'text',
contents
}
})
build.onLoad({ filter: /.*/ }, async (args: OnLoadArgs) => {
if (args.path === ENTRY_FILE_NAME) {
return {