Switch to vite and preact

This commit is contained in:
Misode
2021-06-23 20:44:28 +02:00
parent e551b7ef75
commit 09c851914f
89 changed files with 6398 additions and 15531 deletions

44
vite.config.js Normal file
View File

@@ -0,0 +1,44 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
import html from '@rollup/plugin-html'
import config from './src/config.json'
import { env } from 'process'
export default defineConfig({
build: {
sourcemap: true,
rollupOptions: {
plugins: [
html({
fileName: `404.html`,
title: '404',
template: template,
}),
...config.models.map(m => html({
fileName: `${m.id}/index.html`,
title: getTitle(m),
template: template,
})),
],
},
},
json: {
stringify: true,
},
define: {
__MCDATA_MASTER_HASH__: env ? env.mcdata_hash : '',
__VANILLA_DATAPACK_SUMMARY_HASH__: env ? env.vanilla_datapack_summary_hash : '',
},
plugins: [preact()],
})
function getTitle(m) {
const minVersion = Math.max(0, config.versions.findIndex(v => m.minVersion === v.id))
const versions = config.versions.slice(minVersion).map(v => v.id).join(', ')
return `${m.name} Generator${m.category === true ? 's' : ''} Minecraft ${versions}`
}
function template({ files, title }) {
const source = files.html.find(f => f.fileName === 'index.html').source
return source.replace(/<title>.*<\/title>/, `<title>${title}</title>`)
}