Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
Last active January 25, 2024 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuc-arc-f/c607519d023e8584249b6fcff65372b3 to your computer and use it in GitHub Desktop.
Save kuc-arc-f/c607519d023e8584249b6fcff65372b3 to your computer and use it in GitHub Desktop.
vite.config.ts, svelte sample
VITE_API_URL="http://localhost:4000"
VITE_API_KEY=""
{
"name": "svelte_sample1",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"@tsconfig/svelte": "^5.0.2",
"svelte": "^4.2.8",
"svelte-check": "^3.6.2",
"svelte-spa-router": "^4.0.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
}
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
if (mode === 'production') {
return {
plugins: [svelte()],
define: {
"process.env.NODE_ENV": '"production"',
},
build: {
lib: {
entry: [
'./src/main.ts',
],
formats: ['es'],
fileName: '[name]',
},
rollupOptions: {
output: {
dir: './dist/static'
}
},
emptyOutDir: false,
copyPublicDir: false
}
}
}else{
return {
plugins: [svelte()],
}
}
})
/*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment