This commit is contained in:
2025-11-20 13:10:28 +07:00
parent 1c2c38a8bb
commit 060e3643ea
38 changed files with 18803 additions and 2839 deletions

View File

@@ -1,15 +1,72 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from "vite"
import injectHTML from "vite-plugin-html-inject"
import { resolve } from "node:path"
import fs from "node:fs"
import tailwindcss from "@tailwindcss/vite"
import { fileURLToPath } from "node:url"
// https://vitejs.dev/config/
export default defineConfig({
build: {
outDir: './assets/dist',
minify: false,
rollupOptions: {
output: {
entryFileNames: '[name].js', // Đổi tên của các file JavaScript đầu ra
const __dirname = fileURLToPath(new URL(".", import.meta.url))
const getHtmlFiles = (dir: string): string[] => {
let results: string[] = []
const list = fs.readdirSync(dir)
list.forEach((file) => {
file = resolve(dir, file)
const stat = fs.statSync(file)
if (stat && stat.isDirectory()) {
if (file.endsWith("/partials")) {
return
}
results = results.concat(getHtmlFiles(file))
} else if (file.endsWith(".html")) {
results.push(file)
}
})
return results
}
// Normalize the paths to ensure consistent forward slashes
const normalizePath = (path: string): string => path.split(resolve(__dirname, "src")).join("").replace(/\\/g, "/")
// Use normalizePath function to process the paths correctly
const htmlFiles = getHtmlFiles("src")
const input = Object.fromEntries(
htmlFiles.map((file) => [normalizePath(file).replace(".html", "").replace(/^\//, ""), file])
)
const removecors = () => {
return {
name: "remove-cors",
transformIndexHtml: {
order: "post" as const,
handler(html: string) {
return html.replace(/crossorigin\s*/g, "")
},
},
}
}
export default defineConfig({
base: "",
server: {
open: "/",
},
});
publicDir: "../public",
plugins: [injectHTML(), removecors(), tailwindcss()],
root: "src",
optimizeDeps: {
include: ["filepond", "filepond-plugin-image-preview"],
},
build: {
outDir: "../html",
emptyOutDir: true,
rollupOptions: {
input,
output: {
entryFileNames: `assets/script/[name].js`,
chunkFileNames: `assets/script/[name].js`,
assetFileNames: `assets/script/[name].[ext]`,
},
},
},
})