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