Skip to content

Commit

Permalink
fix js demos on build
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kühn authored and Philipp Kühn committed Dec 16, 2021
1 parent f89abbe commit 688614b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions demos/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,12 @@ export default defineConfig({
transformIndexHtml: {
enforce: 'pre',
transform(html: string, context) {
const data = context.originalUrl?.split('/')

if (!data) {
return
}

const dir = dirname(context.path)
const data = dir.split('/')
const demoCategory = data[2]
const demoName = data[3]

if (context.originalUrl?.endsWith('/JS/')) {
if (dir.endsWith('/JS')) {
return {
html: `
<!DOCTYPE html>
Expand All @@ -76,7 +72,7 @@ export default defineConfig({
}
}

if (context.originalUrl?.endsWith('/Vue/')) {
if (dir.endsWith('/Vue')) {
return {
html: `
<!DOCTYPE html>
Expand All @@ -99,7 +95,7 @@ export default defineConfig({
}
}

if (context.originalUrl?.endsWith('/React/')) {
if (dir.endsWith('/React')) {
return {
html: `
<!DOCTYPE html>
Expand Down

0 comments on commit 688614b

Please sign in to comment.