2022-01-01 14:24:06 +01:00
/// <reference types="vitest" />
2022-02-06 20:11:13 +01:00
import { defineConfig } from 'vite'
2021-10-11 18:40:06 +02:00
import vue from '@vitejs/plugin-vue'
2021-10-07 13:59:10 +02:00
import legacyFn from '@vitejs/plugin-legacy'
2022-02-06 20:11:13 +01:00
2022-04-10 02:40:15 +02:00
import { VitePWA } from 'vite-plugin-pwa'
import { visualizer } from 'rollup-plugin-visualizer'
2021-11-13 14:16:14 +00:00
import svgLoader from 'vite-svg-loader'
2022-04-10 02:40:15 +02:00
import { fileURLToPath , URL } from 'url'
2021-07-25 13:27:15 +00:00
2022-04-10 02:40:15 +02:00
const pathSrc = fileURLToPath ( new URL ( './src' , import . meta . url ) )
2021-08-23 16:39:11 +00:00
2021-09-24 18:08:48 +00:00
// the @use rules have to be the first in the compiled stylesheets
2021-11-22 21:12:54 +00:00
const PREFIXED_SCSS_STYLES = ` @use "sass:math";
@import "${pathSrc}/styles/common-imports" ; `
2021-09-24 18:08:48 +00:00
2021-10-07 13:59:10 +02:00
const isModernBuild = Boolean ( process . env . BUILD_MODERN_ONLY )
const legacy = isModernBuild
? undefined
: legacyFn ( {
// recommended by browserslist => https://github.com/vitejs/vite/tree/main/packages/plugin-legacy#targets
targets : [ 'defaults' , 'not IE 11' ] ,
} )
2022-04-10 02:40:15 +02:00
console . log ( isModernBuild
? 'Building "modern-only" build'
: 'Building "legacy" build with "@vitejs/plugin-legacy"'
)
2021-10-07 13:59:10 +02:00
2022-04-10 02:40:15 +02:00
// https://vitejs.dev/config/
2021-10-07 18:14:00 +00:00
export default defineConfig ( {
2022-01-01 14:24:06 +01:00
// https://vitest.dev/config/
test : {
environment : 'happy-dom' ,
} ,
2021-08-23 16:39:11 +00:00
css : {
preprocessorOptions : {
2021-11-22 21:12:54 +00:00
scss : {
additionalData : PREFIXED_SCSS_STYLES ,
charset : false , // fixes "@charset" must be the first rule in the file" warnings
} ,
2021-08-23 16:39:11 +00:00
} ,
} ,
2021-07-25 13:27:15 +00:00
plugins : [
2021-10-11 18:40:06 +02:00
vue ( {
2022-02-06 20:11:13 +01:00
reactivityTransform : true ,
2021-08-19 20:09:45 +02:00
} ) ,
2021-10-07 13:59:10 +02:00
legacy ,
2021-11-13 14:16:14 +00:00
svgLoader ( {
// Since the svgs are already manually optimized via https://jakearchibald.github.io/svgomg/
// we don't need to optimize them again.
svgo : false ,
} ) ,
2021-07-25 13:27:15 +00:00
VitePWA ( {
2021-07-26 20:26:53 +00:00
srcDir : 'src' ,
2022-02-15 13:07:34 +01:00
filename : 'sw.ts' ,
2021-07-26 20:26:53 +00:00
base : '/' ,
2021-07-25 13:27:15 +00:00
strategies : 'injectManifest' ,
injectRegister : false ,
manifest : {
name : 'Vikunja' ,
short_name : 'Vikunja' ,
theme_color : '#1973ff' ,
icons : [
{
src : './images/icons/android-chrome-192x192.png' ,
sizes : '192x192' ,
type : 'image/png' ,
} ,
{
src : './images/icons/android-chrome-512x512.png' ,
sizes : '512x512' ,
type : 'image/png' ,
} ,
{
src : './images/icons/icon-maskable.png' ,
sizes : '1024x1024' ,
type : 'image/png' ,
purpose : 'maskable' ,
} ,
] ,
start_url : '.' ,
display : 'standalone' ,
background_color : '#000000' ,
shortcuts : [
{
name : 'Overview' ,
url : '/' ,
} ,
{
name : 'Namespaces And Lists Overview' ,
short_name : 'Namespaces & Lists' ,
url : '/namespaces' ,
} ,
{
name : 'Tasks Next Week' ,
short_name : 'Next Week' ,
url : '/tasks/by/week' ,
} ,
{
name : 'Tasks Next Month' ,
short_name : 'Next Month' ,
url : '/tasks/by/month' ,
} ,
{
name : 'Teams Overview' ,
short_name : 'Teams' ,
url : '/teams' ,
} ,
] ,
} ,
} ) ,
] ,
resolve : {
alias : [
{
find : '@' ,
2022-04-10 02:40:15 +02:00
replacement : pathSrc ,
2021-07-25 13:27:15 +00:00
} ,
] ,
extensions : [ '.mjs' , '.js' , '.ts' , '.jsx' , '.tsx' , '.json' , '.vue' ] ,
} ,
server : {
2022-02-18 12:29:39 +01:00
port : 4173 ,
2021-07-25 13:27:15 +00:00
strictPort : true ,
} ,
build : {
rollupOptions : {
2021-08-17 21:17:31 +02:00
plugins : [
2021-08-20 15:17:19 +02:00
visualizer ( {
filename : 'stats.html' ,
} ) ,
2021-07-25 16:02:49 +02:00
] ,
2021-07-25 13:27:15 +00:00
} ,
} ,
2021-10-07 18:14:00 +00:00
} )