9
0
mirror of https://github.com/donlon/cloudflare-error-page.git synced 2025-12-19 14:59:28 +00:00
Files
cloudflare-error-page/editor/web/vite.config.ts
2025-12-19 01:08:24 +08:00

51 lines
1.0 KiB
TypeScript

/// <reference types="vite/types/importMeta.d.ts" />
import { defineConfig } from 'vite';
import { minify as htmlMinify } from 'html-minifier-terser';
import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig(({ mode }) => {
const baseUrl = mode === 'production' ? '' : '/editor/';
return {
appType: 'mpa',
base: baseUrl,
build: {
minify: true,
sourcemap: true,
},
server: {
port: 3000,
proxy: {
'/s/': {
target: 'http://localhost:5000',
},
},
},
plugins: [
{
name: 'html-minifier',
transformIndexHtml: {
order: 'post',
handler(html) {
return htmlMinify(html, {
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
});
},
},
},
viteStaticCopy({
targets: [
{
src: 'assets/',
dest: '',
},
],
}),
],
};
});