1
0
Fork 0
mirror of https://framagit.org/framasoft/mobilizon.git synced 2024-12-23 16:33:28 +00:00
mobilizon/vite.config.js
Thomas Citharel 105d3b5814
test: fix front-end tests
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2023-11-15 12:38:36 +01:00

121 lines
2.8 KiB
JavaScript

import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import path from "path";
import { VitePWA } from "vite-plugin-pwa";
import { visualizer } from "rollup-plugin-visualizer";
export default defineConfig(({ command }) => {
const isDev = command !== "build";
if (isDev) {
// Terminate the watcher when Phoenix quits
process.stdin.on("close", () => {
process.exit(0);
});
process.stdin.resume();
}
const isStory = Boolean(process.env.HISTOIRE);
const plugins = [vue(), visualizer()];
if (!isStory) {
plugins.push(
VitePWA({
registerType: "autoUpdate",
strategies: "injectManifest",
srcDir: "src",
filename: "service-worker.ts",
// injectRegister: "auto",
// devOptions: {
// enabled: true,
// },
manifest: {
name: "Mobilizon",
short_name: "Mobilizon",
orientation: "portrait-primary",
theme_color: "#ffd599",
icons: [
{
src: "./img/icons/android-chrome-192x192.png",
sizes: "192x192",
type: "image/png",
},
{
src: "./img/icons/android-chrome-512x512.png",
sizes: "512x512",
type: "image/png",
},
{
src: "./img/icons/android-chrome-maskable-192x192.png",
sizes: "192x192",
type: "image/png",
purpose: "maskable",
},
{
src: "./img/icons/android-chrome-maskable-512x512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
},
})
);
}
const build = {
manifest: true,
outDir: path.resolve(__dirname, "priv/static"),
emptyOutDir: true,
sourcemap: true,
};
if (!isStory) {
// overwrite default .html entry
build.rollupOptions = {
input: {
main: "src/main.ts",
},
};
}
return {
plugins,
build,
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
unfetch: path.resolve(
__dirname,
"node_modules",
"unfetch",
"dist",
"unfetch.mjs"
),
},
},
css: {
preprocessorOptions: {
scss: {
sassOptions: {
quietDeps: true,
},
},
},
},
test: {
environment: "jsdom",
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
coverage: {
reporter: ["text", "json", "html"],
},
setupFiles: [path.resolve(__dirname, "./tests/unit/setup.ts")],
include: [path.resolve(__dirname, "./tests/unit/specs/**/*.spec.ts")],
},
};
});