How to obfuscate/hash some of the build output file names?

I use a mixpanel NPM package to enable tracking through Mixpanel, but the package's build is called mixpanel.js which doesn't get changed any way when bundled by Nuxt. And this keeps triggering ad blockers when they see something with mixpanel in the URL being requested by the app. So are there any vite/rollup/nuxt build settings I can use to obfuscate the name of the file in the build output or change it to something else?
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
FabiansGeikinsSpeckle
@ArwanceR thanks that put me on the right path. I couldn't use those exact values tho, that broke the build, I think the prefix actually has to be /_nuxt/ not /public. I ended up just using the same approach the vite builder uses in its source code for asset file names:
import { join } from 'path'
import type { OutputOptions } from 'rollup'
import { withoutLeadingSlash } from 'ufo'
import { sanitizeFilePath } from 'mlly'
import { filename } from 'pathe/utils'

// Copied out from nuxt vite-builder source to correctly build output chunk/entry/asset/etc file names
const buildOutputFileName = (chunkName: string) =>
withoutLeadingSlash(
join('/_nuxt/', `${sanitizeFilePath(filename(chunkName))}.[hash].js`)
)
import { join } from 'path'
import type { OutputOptions } from 'rollup'
import { withoutLeadingSlash } from 'ufo'
import { sanitizeFilePath } from 'mlly'
import { filename } from 'pathe/utils'

// Copied out from nuxt vite-builder source to correctly build output chunk/entry/asset/etc file names
const buildOutputFileName = (chunkName: string) =>
withoutLeadingSlash(
join('/_nuxt/', `${sanitizeFilePath(filename(chunkName))}.[hash].js`)
)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server