30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
import { defineConfig } from 'vite';
|
|
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
|
import path from 'path';
|
|
|
|
export default defineConfig({
|
|
plugins: [svelte()],
|
|
// The root is the project root where vite.config.js and package.json are
|
|
root: path.resolve(__dirname),
|
|
// Svelte source code is expected in the 'frontend' subdirectory
|
|
build: {
|
|
outDir: 'static/dist', // Output to a 'static/dist' folder within the project root
|
|
emptyOutDir: true, // Clear the output directory before building
|
|
manifest: true, // Generate manifest.json for Django to read asset paths
|
|
rollupOptions: {
|
|
input: {
|
|
main: 'frontend/main.js', // Entry point for your Svelte app, relative to the 'root'
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: 5173, // Default Vite dev server port
|
|
strictPort: true,
|
|
hmr: { port: 5173 }, // Ensure HMR also uses the correct port
|
|
cors: { // Configure CORS for the Vite development server
|
|
origin: '*', // Allow requests from any origin during development
|
|
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
|
},
|
|
},
|
|
});
|