Skip to content

Commit 17e927c

Browse files
FadySamirSadekmontogeek
authored andcommitted
docs(guides) Replace [chunkhash] with [contenthash] (#2098)
Replaced [chunkhash] with [contenthash] in code examples and defined [contenthash]
1 parent de29be4 commit 17e927c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/content/guides/caching.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ contributors:
66
- jouni-kantola
77
- skipjack
88
- dannycjones
9+
- fadysamirsadek
910
- afontcu
1011
related:
1112
- title: Issue 652
@@ -21,7 +22,7 @@ This guide focuses on the configuration needed to ensure files produced by webpa
2122

2223
## Output Filenames
2324

24-
A simple way to ensure the browser picks up changed files is by using `output.filename` [substitutions](/configuration/output#output-filename). The `[hash]` substitution can be used to include a build-specific hash in the filename, however it's even better to use the `[chunkhash]` substitution which includes a chunk-specific hash in the filename.
25+
A simple way to ensure the browser picks up changed files is by using `output.filename` [substitutions](/configuration/output#output-filename). The `[hash]` substitution can be used to include a build-specific hash in the filename, however it's even better to use the `[contenthash]` substitution which is the hash of the content of a file, which is different for each asset.
2526

2627
Let's get our project set up using the example from [getting started](/guides/getting-started) with the `plugins` from [output management](/guides/output-management), so we don't have to deal with maintaining our `index.html` file manually:
2728

@@ -55,7 +56,7 @@ __webpack.config.js__
5556
],
5657
output: {
5758
- filename: 'bundle.js',
58-
+ filename: '[name].[chunkhash].js',
59+
+ filename: '[name].[contenthash].js',
5960
path: path.resolve(__dirname, 'dist')
6061
}
6162
};
@@ -124,7 +125,7 @@ __webpack.config.js__
124125
      title: 'Caching'
125126
],
126127
output: {
127-
filename: '[name].[chunkhash].js',
128+
filename: '[name].[contenthash].js',
128129
path: path.resolve(__dirname, 'dist')
129130
},
130131
+ optimization: {
@@ -168,7 +169,7 @@ __webpack.config.js__
168169
}),
169170
],
170171
output: {
171-
filename: '[name].[chunkhash].js',
172+
filename: '[name].[contenthash].js',
172173
path: path.resolve(__dirname, 'dist')
173174
},
174175
optimization: {
@@ -295,7 +296,7 @@ __webpack.config.js__
295296
+ new webpack.HashedModuleIdsPlugin()
296297
],
297298
output: {
298-
filename: '[name].[chunkhash].js',
299+
filename: '[name].[contenthash].js',
299300
path: path.resolve(__dirname, 'dist')
300301
},
301302
optimization: {

0 commit comments

Comments
 (0)