mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-24 17:59:05 +01:00
106 lines
2.3 KiB
TypeScript
106 lines
2.3 KiB
TypeScript
import * as fs from "fs";
|
|
import pluginVue from "@vitejs/plugin-vue";
|
|
import { defineConfig } from "vite";
|
|
|
|
import locales from "../../locales";
|
|
import meta from "../../package.json";
|
|
import pluginJson5 from "./vite.json5";
|
|
import viteCompression from "vite-plugin-compression";
|
|
|
|
const isDebug = (process.env.DEBUG === "1" ? true : false) // Enables development mode despite NODE_ENV=production
|
|
|
|
const extensions = [
|
|
".ts",
|
|
".tsx",
|
|
".js",
|
|
".jsx",
|
|
".mjs",
|
|
".json",
|
|
".json5",
|
|
".svg",
|
|
".sass",
|
|
".scss",
|
|
".css",
|
|
".vue",
|
|
];
|
|
|
|
export default defineConfig(({ command, mode }) => {
|
|
fs.mkdirSync(`${__dirname}/../../built`, { recursive: true });
|
|
fs.writeFileSync(
|
|
`${__dirname}/../../built/meta.json`,
|
|
JSON.stringify({ version: meta.version }),
|
|
"utf-8",
|
|
);
|
|
|
|
return {
|
|
base: "/assets/",
|
|
|
|
plugins: [
|
|
pluginVue({
|
|
reactivityTransform: true,
|
|
}),
|
|
pluginJson5(),
|
|
viteCompression({
|
|
algorithm: "brotliCompress",
|
|
verbose: false,
|
|
}),
|
|
],
|
|
|
|
resolve: {
|
|
extensions,
|
|
alias: {
|
|
"@/": `${__dirname}/src/`,
|
|
"/client-assets/": `${__dirname}/assets/`,
|
|
"/static-assets/": `${__dirname}/../backend/assets/`,
|
|
},
|
|
},
|
|
|
|
define: {
|
|
_VERSION_: JSON.stringify(meta.version),
|
|
_LANGS_: JSON.stringify(
|
|
Object.entries(locales).map(([k, v]) => [k, v._lang_]),
|
|
),
|
|
_ENV_: JSON.stringify(process.env.NODE_ENV),
|
|
_DEV_: isDebug,
|
|
_PERF_PREFIX_: JSON.stringify("Misskey:"),
|
|
_DATA_TRANSFER_DRIVE_FILE_: JSON.stringify("mk_drive_file"),
|
|
_DATA_TRANSFER_DRIVE_FOLDER_: JSON.stringify("mk_drive_folder"),
|
|
_DATA_TRANSFER_DECK_COLUMN_: JSON.stringify("mk_deck_column"),
|
|
__VUE_OPTIONS_API__: true,
|
|
__VUE_PROD_DEVTOOLS__: isDebug,
|
|
},
|
|
|
|
build: {
|
|
target: ["chrome87", "firefox78", "safari14", "es2017"],
|
|
manifest: "manifest.json",
|
|
rollupOptions: {
|
|
strictDeprecations: true,
|
|
input: {
|
|
app: "./src/init.ts",
|
|
},
|
|
output: {
|
|
manualChunks: {
|
|
vue: ["vue"],
|
|
},
|
|
},
|
|
},
|
|
cssCodeSplit: true,
|
|
assetsInlineLimit: 0,
|
|
outDir: `${__dirname}/../../built/_client_dist_`,
|
|
assetsDir: ".",
|
|
emptyOutDir: false,
|
|
reportCompressedSize: false,
|
|
commonjsOptions: {
|
|
include: [/trashposs-js/, /node_modules/],
|
|
},
|
|
minify: !isDebug,
|
|
sourcemap: isDebug,
|
|
},
|
|
optimizeDeps: {
|
|
auto: true,
|
|
},
|
|
|
|
logLevel: "warn",
|
|
};
|
|
});
|