Ghost/apps/admin-x-framework/vite.config.ts
Daniel Lockyer 53157f3c40 Disabled reporting compressed gzip size
refs https://vitejs.dev/config/build-options.html#build-reportcompressedsize

- this should make building a little bit quicker because it doesn't have
  to calculate the gzip size (I don't think we're likely to hit this
  because we don't have large projects, but it's still nice to clean up
  the output)
2023-11-15 09:11:12 +01:00

65 lines
2.1 KiB
TypeScript

import react from '@vitejs/plugin-react';
import glob from 'glob';
import {resolve} from 'path';
import {defineConfig} from 'vitest/config';
// https://vitejs.dev/config/
export default (function viteConfig() {
return defineConfig({
plugins: [
react()
],
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.VITEST_SEGFAULT_RETRY': 3
},
preview: {
port: 4174
},
build: {
reportCompressedSize: false,
minify: false,
sourcemap: true,
outDir: 'es',
lib: {
formats: ['es'],
entry: glob.sync(resolve(__dirname, 'src/**/*.{ts,tsx}')).reduce((entries, path) => {
if (path.endsWith('.d.ts')) {
return entries;
}
const outPath = path.replace(resolve(__dirname, 'src') + '/', '').replace(/\.(ts|tsx)$/, '');
entries[outPath] = path;
return entries;
}, {} as Record<string, string>)
},
commonjsOptions: {
include: [/packages/, /node_modules/]
},
rollupOptions: {
external: (source) => {
if (source.startsWith('.')) {
return false;
}
if (source.includes('node_modules')) {
return true;
}
return !source.includes(__dirname);
}
}
},
test: {
globals: true, // required for @testing-library/jest-dom extensions
environment: 'jsdom',
include: ['./test/unit/**/*'],
testTimeout: process.env.TIMEOUT ? parseInt(process.env.TIMEOUT) : 10000,
...(process.env.CI && { // https://github.com/vitest-dev/vitest/issues/1674
minThreads: 1,
maxThreads: 2
})
}
});
});