shlink-web-client/vite.config.ts

67 lines
1.7 KiB
TypeScript
Raw Normal View History

import react from '@vitejs/plugin-react';
import * as path from 'path';
import { VitePWA } from 'vite-plugin-pwa';
2023-05-27 12:36:18 +03:00
import { defineConfig } from 'vitest/config';
import { manifest } from './manifest';
2022-12-26 00:44:43 +03:00
import pack from './package.json';
const homepage = pack.homepage?.trim();
2023-02-18 13:37:49 +03:00
/* eslint-disable-next-line no-restricted-exports */
export default defineConfig({
plugins: [react(), VitePWA({
mode: process.env.NODE_ENV === 'development' ? 'development' : 'production',
strategies: 'injectManifest',
srcDir: './src',
filename: 'service-worker.ts',
injectRegister: false,
manifestFilename: 'manifest.json',
manifest,
})],
build: {
outDir: 'build',
},
server: {
port: 3000,
},
base: !homepage ? undefined : homepage, // Not using just homepage because empty string should be discarded
resolve: {
alias: {
'@shlinkio/shlink-web-component': path.resolve(__dirname, './shlink-web-component/src'),
},
},
2023-05-27 12:36:18 +03:00
2023-05-27 14:12:38 +03:00
// Vitest config
2023-05-27 12:36:18 +03:00
test: {
globals: true,
environment: 'jsdom',
setupFiles: './config/test/setupTests.ts',
coverage: {
2023-06-12 09:51:37 +03:00
provider: 'v8',
2023-05-27 12:36:18 +03:00
reporter: ['text', 'text-summary', 'html', 'clover'],
include: [
'src/**/*.{ts,tsx}',
'shlink-web-component/**/*.{ts,tsx}',
2023-05-27 12:36:18 +03:00
'!src/*.{ts,tsx}',
'!src/reducers/index.ts',
'!src/**/provideServices.ts',
'!src/container/*.ts',
2023-06-12 09:59:38 +03:00
'!src/utils/helpers/sw.ts',
2023-05-27 12:36:18 +03:00
],
// Required code coverage. Lower than this will make the check fail
statements: 95,
branches: 90,
functions: 90,
lines: 95,
2023-05-27 12:36:18 +03:00
},
deps: {
2023-08-10 10:18:22 +03:00
optimizer: {
web: {
include: ['vitest-canvas-mock'],
},
},
2023-05-27 12:36:18 +03:00
},
},
});