2023-10-03 09:53:53 +02:00
|
|
|
import { defineConfig } from "vite";
|
|
|
|
const locales = require("../../locales");
|
|
|
|
const meta = require("../../package.json");
|
|
|
|
|
|
|
|
const isProduction = process.env.NODE_ENV === "production";
|
|
|
|
import viteCompression from "vite-plugin-compression";
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
mode: isProduction ? "production" : "development",
|
|
|
|
build: {
|
2023-10-09 03:40:48 +02:00
|
|
|
target: ["chrome87", "firefox78", "safari14", "es2017"],
|
|
|
|
manifest: "manifest.json",
|
2023-10-03 09:53:53 +02:00
|
|
|
rollupOptions: {
|
2023-10-09 03:40:48 +02:00
|
|
|
input: {
|
|
|
|
app: "./src/sw.ts",
|
|
|
|
},
|
2023-10-03 09:53:53 +02:00
|
|
|
output: {
|
|
|
|
entryFileNames: "sw.js",
|
|
|
|
},
|
|
|
|
},
|
2023-10-09 03:40:48 +02:00
|
|
|
cssCodeSplit: true,
|
|
|
|
assetsInlineLimit: 0,
|
|
|
|
outDir: `${__dirname}/../../built/_sw_dist_`,
|
|
|
|
assetsDir: ".",
|
|
|
|
emptyOutDir: false,
|
|
|
|
sourcemap: process.env.NODE_ENV === "development",
|
|
|
|
reportCompressedSize: false,
|
|
|
|
commonjsOptions: {
|
|
|
|
include: [/firefish-js/, /node_modules/],
|
|
|
|
},
|
2023-10-03 09:53:53 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"@/": `${__dirname}/src/`,
|
|
|
|
},
|
|
|
|
extensions: [".js", ".ts"],
|
|
|
|
},
|
|
|
|
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_: !isProduction,
|
|
|
|
_PERF_PREFIX_: JSON.stringify("Firefish:"),
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
viteCompression({
|
|
|
|
algorithm: "brotliCompress",
|
|
|
|
verbose: false,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
});
|