Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save harpreetkhalsagtbit/dbda5b0f675681f3ea16e5d7af366b2e to your computer and use it in GitHub Desktop.
Save harpreetkhalsagtbit/dbda5b0f675681f3ea16e5d7af366b2e to your computer and use it in GitHub Desktop.
vite-config-with-separate-json-bundle.js
import { resolve } from 'node:path'
import libAssetsPlugin from '@laynezh/vite-plugin-lib-assets'
import { terser } from 'rollup-plugin-terser';
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig(() => ({
plugins: [
libAssetsPlugin({
include: /\.a?json(\?.*)?$/
})
],
build: {
minify:true,
outDir: 'dist', // Specify the output directory for the build
lib: {
entry: resolve('src', 'index.ts'),
name: 'country-state-city',
formats: ['es', 'cjs', 'umd'],
fileName: (format) => `country-state-city.${format}.js`,
},
manifest: true,
rollupOptions: {
plugins: [
terser()
]
},
}
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment