2022-07-12 08:55:28 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2023-11-14 17:59:28 +00:00
|
|
|
const isStory = Boolean(process.env.HISTOIRE);
|
|
|
|
|
|
|
|
const plugins = [vue(), visualizer()];
|
|
|
|
|
|
|
|
if (!isStory) {
|
|
|
|
plugins.push(
|
2022-07-12 08:55:28 +00:00
|
|
|
VitePWA({
|
2023-08-11 10:18:52 +00:00
|
|
|
registerType: "autoUpdate",
|
2022-07-12 08:55:28 +00:00
|
|
|
strategies: "injectManifest",
|
|
|
|
srcDir: "src",
|
|
|
|
filename: "service-worker.ts",
|
|
|
|
// injectRegister: "auto",
|
2022-08-12 14:46:44 +00:00
|
|
|
// devOptions: {
|
|
|
|
// enabled: true,
|
|
|
|
// },
|
2023-08-10 19:50:45 +00:00
|
|
|
manifest: {
|
|
|
|
name: "Mobilizon",
|
|
|
|
short_name: "Mobilizon",
|
|
|
|
orientation: "portrait-primary",
|
2023-08-11 10:18:52 +00:00
|
|
|
theme_color: "#ffd599",
|
2023-08-10 19:50:45 +00:00
|
|
|
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",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-11-14 17:59:28 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
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",
|
2022-07-12 08:55:28 +00:00
|
|
|
},
|
2023-11-14 17:59:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
plugins,
|
|
|
|
build,
|
2022-07-12 08:55:28 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
2023-03-17 17:10:59 +00:00
|
|
|
unfetch: path.resolve(
|
|
|
|
__dirname,
|
|
|
|
"node_modules",
|
|
|
|
"unfetch",
|
|
|
|
"dist",
|
|
|
|
"unfetch.mjs"
|
|
|
|
),
|
2022-07-12 08:55:28 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
css: {
|
|
|
|
preprocessorOptions: {
|
|
|
|
scss: {
|
|
|
|
sassOptions: {
|
|
|
|
quietDeps: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
environment: "jsdom",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
},
|
|
|
|
},
|
2022-09-21 08:33:50 +00:00
|
|
|
coverage: {
|
|
|
|
reporter: ["text", "json", "html"],
|
|
|
|
},
|
2023-11-15 11:29:39 +00:00
|
|
|
setupFiles: [path.resolve(__dirname, "./tests/unit/setup.ts")],
|
2022-08-26 14:08:58 +00:00
|
|
|
include: [path.resolve(__dirname, "./tests/unit/specs/**/*.spec.ts")],
|
2022-07-12 08:55:28 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|