Skip to content

Commit

Permalink
Clean vite setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy committed Oct 24, 2024
1 parent 01dcd18 commit 5ae869f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
7 changes: 7 additions & 0 deletions site/src/pages/Package.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { onDestroy } from 'svelte'
import githubLogo from '../assets/github.svg'
import gitlabLogo from '../assets/gitlab.svg'
import gitLogo from '../assets/git.svg'
Expand Down Expand Up @@ -26,6 +27,12 @@
let error = $state('')
let status = $state('')
onDestroy(() => {
if (worker) {
worker.terminate()
}
})
function createWorker() {
const worker = new Worker(new URL('../utils/worker.js', import.meta.url), {
type: 'module'
Expand Down
32 changes: 4 additions & 28 deletions site/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ export default defineConfig({
// TODO: Fix this in Vite
entries: ['**/*.html', './src/utils/worker.js']
},
plugins: [
spaFallbackWithDot(),
serveAnalysisJson(),
unocss(),
svelte(),
markdown()
],
plugins: [serveAnalysisJson(), unocss(), svelte(), markdown()],
esbuild: {
legalComments: 'none'
},
build: {
rollupOptions: {
input: {
Expand All @@ -28,27 +25,6 @@ export default defineConfig({
}
})

/**
* Vite doesn't handle fallback html with dot (.), see https://github.com/vitejs/vite/issues/2415
* TODO: Review the PR in Vite
* @returns {import('vite').Plugin}
*/
function spaFallbackWithDot() {
return {
name: 'spa-fallback-with-dot',
configureServer(server) {
return () => {
server.middlewares.use((req, res, next) => {
if (req.url.includes('.') && !req.url.endsWith('.html')) {
req.url = '/index.html'
}
next()
})
}
}
}
}

const analysisJsonUrl = new URL(
'../analysis/cache/_results.json',
import.meta.url
Expand Down

0 comments on commit 5ae869f

Please sign in to comment.