Course contentsShow
← Web Development
Lesson 1420 of 2,98225. Build Tools and BundlersFree lesson

Chunk Naming and Output

Configuring meaningful chunk names and output patterns for better debugging.

Chunk Naming and Output

You'll learn how to configure descriptive chunk names and output patterns to make debugging and cache management easier.

When your bundler splits code into chunks (separate files), it needs to name them somehow. By default, you might get cryptic names like 742.js or chunk-ABCD123.js. While these work functionally, they're terrible for debugging, understanding what's in your build, and tracking down performance issues.

Why Chunk Names Matter

Think of chunks like labeled moving boxes. Would you rather open "Box #7" or "Kitchen Dishes"? Meaningful names help you:

  • Debug faster – seeing vendor-react.js is clearer than 1.js
  • Manage cache – content-based hashing ensures browsers fetch updated files
  • Analyze bundles – understand what code is where in your build reports

Configuring Output Patterns

Most bundlers let you define naming patterns using placeholders:

// Vite example
export default {
  build: {
    rollupOptions: {
      output: {
        chunkFileNames: 'chunks/[name]-[hash].js',
        entryFileNames: '[name]-[hash].js',
        assetFileNames: 'assets/[name]-[hash].[ext]'
      }
    }
  }
}

Common placeholders:

  • [name] – the chunk's logical name (route name, vendor group)
  • [hash] – content-based hash for cache busting
  • [ext] – file extension

Strategic Naming

You can also group chunks logically:

manualChunks: {
  'vendor-react': ['react', 'react-dom'],
  'vendor-utils': ['lodash', 'date-fns']
}

This creates clear separation between different types of dependencies.

Key Takeaway: Configuring meaningful chunk names with content hashes transforms your build output from a mystery folder into a well-organized, debuggable, and cache-friendly asset structure.