random name for changable assets
This commit is contained in:
+15
-2
@@ -5,6 +5,15 @@ import vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
|
|||||||
// Utilities
|
// Utilities
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import { fileURLToPath, URL } from 'node:url'
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
import { randomBytes } from 'crypto';
|
||||||
|
|
||||||
|
function getUniqueFileName(template) {
|
||||||
|
if (template.includes('.js') || template.includes('.css')) {
|
||||||
|
const hash = randomBytes(8).toString('hex');
|
||||||
|
return template.replace('[name]', hash);
|
||||||
|
}
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: '',
|
base: '',
|
||||||
@@ -26,8 +35,12 @@ export default defineConfig({
|
|||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
inlineDynamicImports: true,
|
inlineDynamicImports: true,
|
||||||
entryFileNames: 'assets/[name].js',
|
entryFileNames: getUniqueFileName('assets/[name].js'),
|
||||||
assetFileNames: 'assets/[name].[ext]',
|
chunkFileNames: getUniqueFileName('assets/[name].js'),
|
||||||
|
assetFileNames: (assetInfo) => {
|
||||||
|
if (assetInfo.name == "index.css") return getUniqueFileName('assets/[name].css');
|
||||||
|
return 'assets/' + assetInfo.name;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user