Update Vite configuration to support foliate-js library integration:
1. Add import alias for foliate-js:
- Maps 'foliate-js' imports to web/vendor/foliate-js submodule
- Allows clean imports: import { View } from 'foliate-js/view.js'
2. Update build target to ESNext:
- Change from 'es2020' to 'esnext' to support top-level await
- Required by foliate-js pdf.js which uses top-level await
- ES2022+ support is excellent in all modern browsers (Chrome 112+, Firefox 115+, Safari 16.4+)
These changes enable Vite to bundle foliate-js into reader.js without
requiring a separate build step for the library.
28 lines
540 B
TypeScript
28 lines
540 B
TypeScript
import { defineConfig } from "vite";
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: {
|
|
"@": "/web/src",
|
|
"foliate-js": "/web/vendor/foliate-js",
|
|
},
|
|
},
|
|
base: "/static/",
|
|
build: {
|
|
outDir: "web/static",
|
|
emptyOutDir: false,
|
|
assetsDir: "",
|
|
rollupOptions: {
|
|
input: {
|
|
main: "web/src/main.ts",
|
|
reader: "web/src/reader/reader.ts",
|
|
},
|
|
output: {
|
|
entryFileNames: "[name].js",
|
|
},
|
|
},
|
|
target: "esnext",
|
|
sourcemap: true,
|
|
minify: "esbuild",
|
|
},
|
|
});
|