2023-04-07 03:56:46 +02:00
|
|
|
import * as fs from "fs";
|
|
|
|
import pluginVue from "@vitejs/plugin-vue";
|
|
|
|
import { defineConfig } from "vite";
|
2022-05-01 15:51:07 +02:00
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
import locales from "../../locales";
|
|
|
|
import meta from "../../package.json";
|
|
|
|
import pluginJson5 from "./vite.json5";
|
|
|
|
import viteCompression from "vite-plugin-compression";
|
2022-05-01 15:51:07 +02:00
|
|
|
|
2023-04-07 03:56:46 +02:00
|
|
|
const extensions = [
|
|
|
|
".ts",
|
|
|
|
".tsx",
|
|
|
|
".js",
|
|
|
|
".jsx",
|
|
|
|
".mjs",
|
|
|
|
".json",
|
|
|
|
".json5",
|
|
|
|
".svg",
|
|
|
|
".sass",
|
|
|
|
".scss",
|
|
|
|
".css",
|
|
|
|
".vue",
|
|
|
|
];
|
2022-05-01 15:51:07 +02:00
|
|
|
|
2023-01-10 17:49:15 +01:00
|
|
|
export default defineConfig(({ command, mode }) => {
|
2023-07-11 07:34:04 +02:00
|
|
|
fs.mkdirSync(`${__dirname}/../../built`, { recursive: true });
|
2023-04-07 03:56:46 +02:00
|
|
|
fs.writeFileSync(
|
2023-07-11 07:34:04 +02:00
|
|
|
`${__dirname}/../../built/meta.json`,
|
2023-04-07 03:56:46 +02:00
|
|
|
JSON.stringify({ version: meta.version }),
|
|
|
|
"utf-8",
|
|
|
|
);
|
2023-01-11 19:48:17 +01:00
|
|
|
|
2022-05-01 15:51:07 +02:00
|
|
|
return {
|
2023-04-07 03:56:46 +02:00
|
|
|
base: "/assets/",
|
2022-05-01 15:51:07 +02:00
|
|
|
|
|
|
|
plugins: [
|
|
|
|
pluginVue({
|
|
|
|
reactivityTransform: true,
|
|
|
|
}),
|
|
|
|
pluginJson5(),
|
2023-03-19 08:26:26 +01:00
|
|
|
viteCompression({
|
2023-04-07 03:56:46 +02:00
|
|
|
algorithm: "brotliCompress",
|
2023-07-11 07:34:04 +02:00
|
|
|
verbose: false,
|
2023-03-19 08:26:26 +01:00
|
|
|
}),
|
2022-05-01 15:51:07 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
extensions,
|
|
|
|
alias: {
|
2023-07-11 07:34:04 +02:00
|
|
|
"@/": `${__dirname}/src/`,
|
|
|
|
"/client-assets/": `${__dirname}/assets/`,
|
|
|
|
"/static-assets/": `${__dirname}/../backend/assets/`,
|
2022-05-01 15:51:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
define: {
|
|
|
|
_VERSION_: JSON.stringify(meta.version),
|
2023-04-07 03:56:46 +02:00
|
|
|
_LANGS_: JSON.stringify(
|
|
|
|
Object.entries(locales).map(([k, v]) => [k, v._lang_]),
|
|
|
|
),
|
2022-05-01 15:51:07 +02:00
|
|
|
_ENV_: JSON.stringify(process.env.NODE_ENV),
|
2023-04-07 03:56:46 +02:00
|
|
|
_DEV_: process.env.NODE_ENV !== "production",
|
|
|
|
_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"),
|
2022-05-01 15:51:07 +02:00
|
|
|
__VUE_OPTIONS_API__: true,
|
|
|
|
__VUE_PROD_DEVTOOLS__: false,
|
|
|
|
},
|
|
|
|
|
|
|
|
build: {
|
2023-04-07 03:56:46 +02:00
|
|
|
target: ["chrome87", "firefox78", "safari14", "es2017"],
|
|
|
|
manifest: "manifest.json",
|
2022-05-01 15:51:07 +02:00
|
|
|
rollupOptions: {
|
|
|
|
input: {
|
2023-04-07 03:56:46 +02:00
|
|
|
app: "./src/init.ts",
|
2022-05-01 15:51:07 +02:00
|
|
|
},
|
|
|
|
output: {
|
|
|
|
manualChunks: {
|
2023-04-07 03:56:46 +02:00
|
|
|
vue: ["vue"],
|
2022-05-01 15:51:07 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cssCodeSplit: true,
|
2023-01-11 19:48:17 +01:00
|
|
|
assetsInlineLimit: 0,
|
2023-07-11 07:34:04 +02:00
|
|
|
outDir: `${__dirname}/../../built/_client_dist_`,
|
2023-04-07 03:56:46 +02:00
|
|
|
assetsDir: ".",
|
2022-05-01 15:51:07 +02:00
|
|
|
emptyOutDir: false,
|
2023-04-07 03:56:46 +02:00
|
|
|
sourcemap: process.env.NODE_ENV === "development",
|
2023-01-11 19:48:17 +01:00
|
|
|
reportCompressedSize: false,
|
2023-04-08 02:44:27 +02:00
|
|
|
commonjsOptions: {
|
|
|
|
include: [/calckey-js/, /node_modules/],
|
|
|
|
},
|
2022-05-01 15:51:07 +02:00
|
|
|
},
|
2022-12-27 00:24:19 +01:00
|
|
|
optimizeDeps: {
|
2023-01-11 19:50:46 +01:00
|
|
|
auto: true,
|
2022-12-27 00:24:19 +01:00
|
|
|
},
|
2023-07-11 07:34:04 +02:00
|
|
|
|
|
|
|
logLevel: 'warn',
|
2022-06-20 10:38:49 +02:00
|
|
|
};
|
2022-05-01 15:51:07 +02:00
|
|
|
});
|