Skip to content

Commit

Permalink
fix: build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Jun 11, 2024
1 parent b64fc10 commit 1e3e00b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ public
coverage
src/registerServiceWorker.js
cypress/integration/examples
commitlint.config.js
commitlint.config.cjs
File renamed without changes.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"Fanny Lasne",
"Basile Spaenlehauer"
],
"type": "module",
"homepage": ".",
"dependencies": {
"@emotion/react": "11.11.4",
Expand Down
38 changes: 15 additions & 23 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
/// <reference types="./src/env.d.ts"/>
/// <reference types="./src/env"/>
import { resolve } from 'path';
import { visualizer } from 'rollup-plugin-visualizer';
import { PluginOption, UserConfigExport, defineConfig, loadEnv } from 'vite';
import { UserConfigExport, defineConfig, loadEnv } from 'vite';
import checker from 'vite-plugin-checker';
import istanbul from 'vite-plugin-istanbul';

import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
const config = ({ mode }: { mode: string }): UserConfigExport => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
export default ({ mode }: { mode: string }): UserConfigExport => {
process.env = {
VITE_VERSION: 'default',
VITE_BUILD_TIMESTAMP: new Date().toISOString(),
...process.env,
...loadEnv(mode, process.cwd()),
};

return defineConfig({
base: '',
server: {
port: parseInt(process.env.VITE_PORT || '3001', 10),
// only auto open the app when in dev mode
open: mode === 'development',
port: parseInt(process.env.VITE_PORT, 10) || 4001,
open: mode !== 'test', // open only when mode is different from test
watch: {
ignored: ['**/coverage/**', '**/cypress/downloads/**'],
},
},
preview: {
port: parseInt(process.env.VITE_PORT || '3005', 10),
port: parseInt(process.env.VITE_PORT || '3333', 10),
strictPort: true,
},
build: {
Expand All @@ -33,8 +36,9 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
? undefined
: checker({
typescript: true,
eslint: { lintCommand: 'eslint "./**/*.{ts,tsx}"' },
overlay: { initialIsOpen: false },
eslint: {
lintCommand: 'eslint "src/**/*.{ts,tsx}"',
},
}),
react(),
istanbul({
Expand All @@ -45,17 +49,6 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
forceBuildInstrument: mode === 'test',
checkProd: true,
}),
...(mode === 'development'
? [
visualizer({
template: 'treemap', // or sunburst
open: true,
gzipSize: true,
brotliSize: true,
filename: 'bundle_analysis.html',
}) as PluginOption,
]
: []),
],
resolve: {
alias: {
Expand All @@ -64,4 +57,3 @@ const config = ({ mode }: { mode: string }): UserConfigExport => {
},
});
};
export default config;

0 comments on commit 1e3e00b

Please sign in to comment.