Skip to content

Commit

Permalink
feat(dev): use vite plugin static-copy to copy report data in build f…
Browse files Browse the repository at this point in the history
…older

Can now use "vite dev" with HMR, instead of building app every time during developments.
  • Loading branch information
Thibaut-gauvin committed Jun 24, 2024
1 parent eade624 commit 2bb9475
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 5 deletions.
72 changes: 71 additions & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"private": true,
"scripts": {
"dev": "vite dev",
"cp:fixtures": "cp -r ./fixtures/report-data/dev/* ./build/",
"build": "vite build",
"start": "npm run build && npm run cp:fixtures && npx serve -p 3000 build/",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
Expand All @@ -15,6 +13,7 @@
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.7",
"@types/node": "^20.14.8",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0",
Expand All @@ -26,7 +25,8 @@
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"typescript-eslint": "^8.0.0-alpha.20",
"vite": "^5.0.3"
"vite": "^5.0.3",
"vite-plugin-static-copy": "^1.0.5"
},
"type": "module"
}
13 changes: 12 additions & 1 deletion client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { resolve } from 'path';

// Copy report data fixtures only during development
const viteStaticCopyReportData = viteStaticCopy({
targets: [
{
src: resolve('./fixtures/report-data/dev/*'),
dest: './'
}
]
});

/** @type {import('vite').UserConfig} */
const config = {
plugins: [sveltekit()],
plugins: [sveltekit(), process.env.NODE_ENV !== 'production' ? viteStaticCopyReportData : null],
resolve: {
alias: {
$models: resolve('src/models'),
Expand Down

0 comments on commit 2bb9475

Please sign in to comment.