load custom js when the app is done loading to ease custom code usage (#1093)

This commit is contained in:
Athou
2023-12-31 09:14:48 +01:00
parent 96212afd27
commit 6e5f362a8e
2 changed files with 39 additions and 30 deletions

View File

@@ -1,41 +1,13 @@
import { lingui } from "@lingui/vite-plugin"
import react from "@vitejs/plugin-react"
import { visualizer } from "rollup-plugin-visualizer"
import { defineConfig, PluginOption } from "vite"
import { defineConfig } from "vite"
import eslint from "vite-plugin-eslint"
import tsconfigPaths from "vite-tsconfig-paths"
// inject custom js and css links in html
const customCodeInjector: PluginOption = {
name: "customCodeInjector",
transformIndexHtml: html => {
return {
html,
tags: [
{
tag: "script",
attrs: {
src: "custom_js.js",
},
injectTo: "body",
},
{
tag: "link",
attrs: {
rel: "stylesheet",
href: "custom_css.css",
},
injectTo: "head",
},
],
}
},
}
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
customCodeInjector,
react({
babel: {
// babel-macro is needed for lingui