-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Copy link
Description
Environment
import tsconfigPaths from 'vite-tsconfig-paths';
import pkg from './package.json';
import * as fs from "fs";
import { createHash } from 'crypto';
const dev = process.env.NUXT_PUBLIC_APP_DEBUG === 'true' || false;
const versionHash = createHash('sha256').update(pkg.version).digest('hex').slice(0, 10)+'20';
export default defineNuxtConfig({
dev,
// debug: dev,
devtools: {
enabled: false
},
features:{
devLogs: dev,
},
appConfig: {
nuxt: {
buildId: versionHash,
},
},
experimental: {
appManifest: true,
cookieStore: true,
// emitRouteChunkError: 'reload',
treeshakeClientOnly: true,
payloadExtraction: true,
// inlineSSRStyles: true,
writeEarlyHints: false,
// viewTransition: true,
renderJsonPayloads: true,
componentIslands: {
selectiveClient: true
}
},
runtimeConfig: {
public: {
},
},
security: {
// Options
sri: true,
headers:{
contentSecurityPolicy: false,
permissionsPolicy: false
},
// corsHandler:{
// origin: '*'
// },
removeLoggers: false,
rateLimiter: false,
csrf: false,
// csrf: {
// addCsrfTokenToEventCtx: true
// },
hidePoweredBy: true
},
app: {
buildAssetsDir: `/${versionHash}/`
},
routeRules: {
'/':{
cache: false, // issue related with this ticket https://github.com/nuxt/nuxt/issues/31733
// if set to anything other than false, it will cache the page and expireOnReload for system modals,
// and probably some auth features won't work properly
},
},
modules: [
'nuxt-security',
'@nuxt/eslint',
'@nuxt/test-utils/module',
'@pinia/nuxt',
'@vueuse/nuxt',
'@nuxt/image'
],
pages: true,
plugins: [],
inkline: {
css: false,
colorMode: 'light'
},
ignore: [
'**/*.test.*',
'**/*.spec.*',
'**/__tests__/**',
'**/__helper__/**'
],
sourcemap: {
server: dev,
client: dev
},
vite: {
build: {
analyze: false,
assetsDir: `${versionHash}/`,
cssCodeSplit: dev,
rollupOptions: {
// output: {
// chunkFileNames: `[hash].js`,
// entryFileNames: `[hash].js`
// }
// preserveEntrySignatures: 'strict',
output: {
// preserveModules: true,
// assetFileNames: `[hash].${versionHash}.[extname]`,
// chunkFileNames: `_nuxt/[name].[hash].${versionHash}.js`,
// entryFileNames: `_nuxt/[name].[hash].${versionHash}.js`,
// assetFileNames: `_nuxt/[name].[hash].${versionHash}.[ext]`
chunkFileNames: `${versionHash}/[hash].js`,
entryFileNames: `${versionHash}/[hash].js`,
assetFileNames: `${versionHash}/[hash].[ext]`
},
}
},
$client: {
build: {
rollupOptions: {
//preserveEntrySignatures: 'strict',
output: {
//preserveModules: true,
// chunkFileNames: `[hash].js`,
// assetFileNames: `[hash].${versionHash}.[extname]`,
// entryFileNames: `[hash].js`
// chunkFileNames: `_nuxt/[name].[hash].${versionHash}.js`,
// entryFileNames: `_nuxt/[name].[hash].${versionHash}.js`,
// assetFileNames: `_nuxt/[name].[hash].${versionHash}.[ext]`
// chunkFileNames: `${versionHash}/[hash].js`,
// entryFileNames: `${versionHash}/[hash].js`,
// assetFileNames: `${versionHash}/[hash].[ext]`
},
}
}
},
$server: {
build: {
rollupOptions: {
// preserveEntrySignatures: 'strict',
output: {
// preserveModules: true,
// chunkFileNames: `[hash].js`,
// assetFileNames: `[hash].${versionHash}.[extname]`,
// entryFileNames: `[hash].js`
// chunkFileNames: `${versionHash}/[hash].js`,
// entryFileNames: `${versionHash}/[hash].js`,
// assetFileNames: `${versionHash}/[hash].[ext]`
}
}
}
},
plugins: [
tsconfigPaths()
]
},
nitro: {
runtimeConfig:{
app:{
buildAssetsDir: `/${versionHash}/`
}
}
},
buildModules: [],
serverMiddleware: [],
compatibilityDate: '2024-07-09'
});
Reproduction
- enable
componentIslands: { selectiveClient: true }
- set buildAssetsDir to something other than
/_nuxt/
, for example/07332f681020/
(is a version hash) - build project in production env
- run
Describe the bug
When componentIslands enabled, components that affected by this feature, ignores buildAssetsDir
and/or rollup chunk/entry/asset name. And does not update file name hashes even if component code was changed.
Component url will still look like that:
http://localhost:3000/07332f681020/_nuxt/nJKChgM0-iThgYsLbhDKxBipcnkOFskrNVzUzZPaAts.mjs
Because in packages/nuxt/src/components/plugins/islands-transform.ts this prefix is hardcoded.
Additional context
Logs
ℹ .nuxt/dist/client/_nuxt/50d7voHYhuKqnMKNznk3oEad6wr2C6dVyaABZ4e9MIY.mjs 30.47 kB │ gzip: 8.68 kB │ map: 86.81 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/CTj3wtXK.js 31.95 kB │ gzip: 12.72 kB │ map: 129.11 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/CHn4e8y7.js 45.88 kB │ gzip: 15.66 kB │ map: 296.80 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/CZBadJsd.js 66.85 kB │ gzip: 21.93 kB │ map: 804.86 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/nlxHiInU_dOaUsy8ulFNboPIHOQjxJZ9pLfJ6QkEO30.mjs 77.48 kB │ gzip: 28.83 kB │ map: 722.68 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/BUwo4SN7.js 80.86 kB │ gzip: 28.51 kB │ map: 317.28 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/BXp7EdZy.js 86.13 kB │ gzip: 15.69 kB │ map: 153.94 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/27fGWhp6JvuM8CBiy1zJxQNtI02fI1W0b6ieGM-RfCY.mjs 92.48 kB │ gzip: 14.35 kB │ map: 102.02 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/CxTKD_hA.js 94.73 kB │ gzip: 38.31 kB │ map: 521.00 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/CRklDFRt.js 95.70 kB │ gzip: 35.99 kB │ map: 384.34 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/-_HcLey7FUhHrPqXZzqFsVcMbmB4GvDkkhflTi4b8Bw.mjs 97.89 kB │ gzip: 34.59 kB │ map: 447.16 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/D4CNKM0Z.js 134.92 kB │ gzip: 47.17 kB │ map: 591.75 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/BHhL4lb5.js 148.93 kB │ gzip: 51.37 kB │ map: 386.54 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/HdBnhJze.js 149.42 kB │ gzip: 43.25 kB │ map: 652.69 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/tbOz20miHcZ_qlahPkCBPMLykLvUfNM1dgyvj0i0gLk.mjs 161.77 kB │ gzip: 56.76 kB │ map: 805.15 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/Nn1xFzYUFRWoXpZHAQtRVMWCNqQLJTo8Ef3sdV1aeIs.mjs 172.31 kB │ gzip: 51.11 kB │ map: 762.55 kB 3:28:49 PM
ℹ .nuxt/dist/client/07332f681020/BZxblqkm.js 590.62 kB │ gzip: 218.41 kB │ map: 937.73 kB 3:28:49 PM
ℹ .nuxt/dist/client/_nuxt/l561p2ThXEREUH78-zPIkxzK7hJgbaciKjNPtmuNy5U.mjs 688.64 kB │ gzip: 205.81 kB │ map: 3,162.90 kB