Enhance Vite configuration with Rollup options for output file naming and add JSON stringification. Update web.config to serve .js and .mjs files with the correct MIME type.

This commit is contained in:
2025-04-18 04:32:27 -04:00
parent b3bdd928b1
commit e21020e5aa
2 changed files with 19 additions and 1 deletions

View File

@@ -21,7 +21,15 @@ export default defineConfig(({mode}) => {
host: 'localhost',
},
build: {
sourcemap: true // Enable source maps for debugging
sourcemap: true, // Enable source maps for debugging
rollupOptions: {
output: {
format: 'es',
entryFileNames: '[name].[hash].js',
chunkFileNames: '[name].[hash].js',
assetFileNames: '[name].[hash].[ext]'
}
}
},
resolve: {
alias: {
@@ -32,6 +40,9 @@ export default defineConfig(({mode}) => {
// Define a global constant __APP_ENV__ based on loaded environment variables
VITE_API_URL: JSON.stringify(env.VITE_API_URL),
VITE_STRIPE_API_KEY: JSON.stringify(env.VITE_STRIPE_API_KEY)
},
json: {
stringify: true
}
}
})

View File

@@ -3,6 +3,13 @@
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".js" mimeType="application/javascript" />
<mimeMap fileExtension=".mjs" mimeType="application/javascript" />
</staticContent>
<httpProtocol>
<customHeaders>
<add name="Content-Type" value="application/javascript" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>