N
Nuxt2w ago
DANANZ

How to disable file names minification during build

After build, the js files under dist folder gets a minified js name, is there any way to prevent this from happening ? (for debug purposes only)
No description
17 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: ---------------------- The knowledge sources do not explicitly mention a built-in Nuxt config option to fully disable JS file name minification (hashing/obfuscation) in the build output. However, you can influence the output file names by customizing Vite's build options in your nuxt.config.ts. For debug purposes, you can set custom file names using Vite's rollupOptions.output:
export default defineNuxtConfig({
vite: {
build: {
rollupOptions: {
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]',
}
}
}
}
})
export default defineNuxtConfig({
vite: {
build: {
rollupOptions: {
output: {
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
assetFileNames: '[name][extname]',
}
}
}
}
})
This configuration will generate files with their original names instead of hashed/minified ones, making debugging easier. Note that this approach is referenced in the context of customizing file names, and is not the default Nuxt behavior, but it is supported via Vite's configuration layer, which Nuxt exposes for advanced use cases. Be aware that overriding these options may affect how Nuxt manages assets and caching, so use it only for debugging and not in production environments Page navigation with Nuxt3/Electron not working - not allowed to load local resource with '' Part 2. If you want to add a prefix to asset file names (not disable minification), Nuxt 3.16+ introduces the buildAssetsFileNamePrefix option, but this does not remove hashing/minification, only adds a prefix feat: add buildAssetsFileNamePrefix option. Summary:
- Use Vite's rollupOptions.output in nuxt.config.ts to control file naming for debugging. - There is no official Nuxt config to fully disable file name minification, but Vite's options provide a workaround. - Do not use this in production, as it may impact caching and asset management. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ
DANANZOP2w ago
@kapa.ai but now its failing to resolve these paths
No description
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If you override the default hashed file naming in Nuxt/Vite (for example, by setting entryFileNames: '[name].js' and similar options), you may encounter issues where the application fails to resolve or load these files after build. This is because Nuxt's asset resolution, routing, and cache-busting mechanisms are designed around the default hashed filenames. Changing this can break the mapping between your app's runtime requests and the actual files in the output directory. The knowledge sources confirm that Nuxt's chunk and asset management is tightly coupled with its default file naming and hashing strategy. For example, there are references to issues where changes in chunk naming or asset resolution led to 404 errors or failed dynamic imports, especially in production or when using custom build setups Failed to fetch dynamically imported module "/_nuxt/OpeningHours.CTqYYKGj.js", feat(nuxt,vite): use importmap to increase chunk stability. If you need to debug with non-minified file names, be aware that: - Nuxt may not be able to resolve or serve these files correctly, leading to runtime errors or 404s. - Features like dynamic imports, code-splitting, and cache-busting may not work as expected. - There is no official support or documented workaround for disabling file name minification without breaking asset resolution. If you are seeing path resolution failures after changing the file naming, it is likely due to these internal dependencies on the default naming scheme. The knowledge sources do not provide a supported way to fully disable file name minification while maintaining correct path resolution in Nuxt. Recommendation:
For debugging, consider using source maps and the default build process, rather than changing file naming conventions. If you must customize file names, be prepared for potential breakage and use this only in isolated, non-production environments. If you need more robust debugging, you might want to look into Nuxt's dev mode or Vite's development server, which do not use hashed file names and are designed for easier debugging without these resolution issues. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ
DANANZOP2w ago
@kapa.ai how can I minify the index.js file?
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry, but the knowledge sources provided do not contain explicit information or instructions on how to specifically minify the index.js file in a Nuxt project. While there are references to general build and minification processes in Nuxt (handled by Vite/Rollup), there is no direct documentation or example for targeting and minifying a specific file like index.js. If you need more detailed guidance, please provide additional context or refer to Nuxt/Vite documentation for advanced build customization. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ
DANANZOP2w ago
@kapa.ai how can I optimize and decrease the filesize the index.js file? @kapa.ai how can I optimize and decrease the filesize of index.js file?
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To optimize and decrease the filesize of your Nuxt project's main JavaScript bundle (such as index.js or entry.js), the knowledge sources recommend several strategies: - Use Dynamic Imports and Code Splitting:
Large chunks can be split using dynamic import() statements. This allows Nuxt/Vite/Rollup to generate smaller, on-demand JS files, reducing the size of the main bundle. You can also use build.rollupOptions.output.manualChunks to further control chunking Nuxt3 build .output folder remains empty, nothing copied from .nuxt Part 2, watcher scans all files in root directory. - Remove Unused Dependencies:
Analyze your bundle with tools like Vite Bundle Visualizer or Rollup Plugin Visualizer to identify and remove unused or large dependencies Vite Bundle Inspection made EASY. - Lazy Load Components and Use Lazy Hydration:
Only load components when needed and use lazy hydration to reduce the initial JS payload add performance best practices section. - Optimize Images and Fonts:
Use Nuxt modules like Nuxt Image and Nuxt Fonts to optimize non-JS assets, which can indirectly reduce JS bundle size by removing inlined assets add performance best practices section. - Profile and Analyze:
Use tools such as Nuxi Analyze, Nuxt DevTools, Chrome DevTools, and PageSpeed Insights to measure and analyze your bundle size and performance add performance best practices section. - Avoid Overusing Plugins and Unused Code:
Only include necessary plugins and code in your project to keep the bundle lean add performance best practices section. - Leverage Hybrid Rendering and Server Components:
Render as much as possible on the server to reduce client-side JS add performance best practices section. Summary:
Focus on code splitting, removing unused dependencies, lazy loading, and using profiling tools to optimize your main JS bundle. These are the recommended and supported ways to decrease the filesize of your main Nuxt JS file according to the official best practices and community experience. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ
DANANZOP2w ago
@kapa.ai is there a way to see the actual file name after build?
No description
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Yes, you can see the actual file names generated after the build in several ways: 1. Check the Build Output Logs:
During the build process, Nuxt outputs a list of generated files and their sizes directly in the terminal. This includes the actual file names for your JS, CSS, and other assets. For example, you might see lines like:
[info] ../.nuxt/dist/client/_nuxt/entry.BlgYmPsC.css 98.62 kB │ gzip: 15.71 kB
[info] ../.nuxt/dist/client/_nuxt/PalxAwQ_.js 0.06 kB │ gzip: 0.08 kB

[info] ../.nuxt/dist/client/_nuxt/entry.BlgYmPsC.css 98.62 kB │ gzip: 15.71 kB
[info] ../.nuxt/dist/client/_nuxt/PalxAwQ_.js 0.06 kB │ gzip: 0.08 kB

This shows the real file names as they exist in the output directory watcher scans all files in root directory. 2. Inspect the Output Directory:
After the build, you can look directly in the .output, .nuxt/dist/client, or similar output folders to see the actual file names that were generated. 3. Use Nuxt DevTools:
The DevTools provide a "Build Analyze" tab where you can run an analysis and see the bundle size and file names of your project. This can help you inspect which files were generated and their sizes Guide: Features. These methods allow you to see the real file names produced by the Nuxt build process. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
DANANZ
DANANZOP2w ago
@kapa.ai theres a nuxt config setting to allow me to see the file names?
kapa.ai
kapa.ai2w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry, but the knowledge sources do not mention a specific Nuxt config setting that will display the generated file names directly as part of the build process output. However, the build logs printed in the terminal during nuxt build do show the actual file names and their sizes as part of the standard output. You can also inspect the output directories (such as .output or .nuxt/dist/client) after building to see the file names watcher scans all files in root directory. Additionally, Nuxt DevTools offers a "Build Analyze" tab, which allows you to analyze your build and see the bundle size and file names of your project Guide: Features. But to summarize:
There is no dedicated Nuxt config setting to enable or enhance file name visibility in the build output—the standard build logs and DevTools are the recommended ways to view them. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@496347982963408899> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?