unminimize the function in build

how can I tell nuxt to show the actual function names from the build? and not minimize the functions?
No description
3 Replies
kapa.ai
kapa.ai2w ago
Hi @Dananz. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To unminimize functions in the Nuxt build and show actual function names, you can adjust the webpack configuration in your nuxt.config.ts file. Here's how you can do it: 1. Set the minimize option to false in the webpack optimization configuration:
export default defineNuxtConfig({
webpack: {
optimization: {
minimize: false
}
}
})
export default defineNuxtConfig({
webpack: {
optimization: {
minimize: false
}
}
})
This will disable all minimizers for the webpack build, as mentioned in the Nuxt Configuration documentation (https://nuxt.com/docs/api/nuxt-config#optimization-1). 2. If you want to keep other optimizations but just prevent function name mangling, you can customize the terser options:
export default defineNuxtConfig({
webpack: {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
keep_fnames: true,
mangle: false
}
})
]
}
}
})
export default defineNuxtConfig({
webpack: {
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
keep_fnames: true,
mangle: false
}
})
]
}
}
})
Note that you'll need to import TerserPlugin from 'terser-webpack-plugin' at the top of your config file. These changes will help preserve function names in your build output. However, keep in mind that disabling minimization or name mangling will increase your bundle size, which may affect load times in production. It's generally recommended to use these settings only for debugging purposes. Additionally, for better debugging in general, you might want to enable source maps. You can do this by setting the sourcemap option in your Nuxt configuration:
export default defineNuxtConfig({
sourcemap: {
server: true,
client: true
}
})
export default defineNuxtConfig({
sourcemap: {
server: true,
client: true
}
})
This will generate source maps for both server and client builds, as described in the Nuxt debugging documentation (https://nuxt.com/docs/guide/going-further/debugging#sourcemaps). Remember that these settings are typically used for development or debugging purposes. For production builds, it's usually best to keep minimization enabled for optimal performance. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@970727290772283392> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ M1
DANANZ M1OP2w ago
didnt helped and still everything is minimized.... it seems like the suggestion from the docs does not really works

webpack: {
optimization: {
minimize: false,
},
},

webpack: {
optimization: {
minimize: false,
},
},
Want results from more Discord servers?
Add your server