Migrate interkit to vite (Apps before April 2023)

(See commit 6dab1378)

Rename

  • rename public to static
  • move public/index.html one up to index.html

Add

  • add vite.config.js:
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [svelte()],
  base: "./",
  publicDir: "static",
  server: {
    port: 8000
  },
  build: {
    outDir: "public",
    target: "es2015",
  },
})

Delete

  • delete rollup.config.js

Modify

  • .gitignore
-public/build/
+public/
  • index.html in <head>:

-  <link rel='stylesheet' href='build/bundle.css'>
-  <script>
-    document.addEventListener('DOMContentLoaded', function() {
-      var src = (new URLSearchParams(window.location.search)).get('dev') ? 'build/bundle_dev.js' : 'build/bundle.js'
-      var scriptTag = document.createElement('script');
-      scriptTag.setAttribute('defer', true);
-      scriptTag.setAttribute('src', src);
-      document.head.appendChild(scriptTag);
-    })
-  </script>
  • index.html in <body>:
-  <div class="Loading" style="padding: 20px">laden...</div>
+  <div id="app"></div>
+  <script type="module" src="/src/main.js"></script>
  • package.json
 "scripts": {
-    "build": "rollup -c",
+    "build": "vite build",
     "start": "sirv public",
-    "build:dev": "QUICK_COMPILE=true rollup -c",
-    "dev": "rollup -c -w"
+    "preview": "vite preview",
+    "build:dev": "npm run build",
+    "dev": "vite"
   },