kopia lustrzana https://github.com/learn-awesome/learndb
Generating alltopics.json for the mapview at build time
rodzic
db5025a31c
commit
13cb93bc08
|
@ -1,7 +1,21 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
||||
|
||||
import { topics } from './db/topics.js'
|
||||
import fs from 'fs';
|
||||
|
||||
function generateTopicJSON(){
|
||||
console.log("Generating public/alltopics.json ...")
|
||||
const topics_db = topics.trimStart().trimEnd().split('\n').map(j => JSON.parse(j));
|
||||
try {
|
||||
fs.writeFileSync('public/alltopics.json', JSON.stringify(topics_db));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
plugins: [generateTopicJSON(),svelte()],
|
||||
})
|
Ładowanie…
Reference in New Issue