There was an error while loading. Please reload this page.
1 parent 2875778 commit 3902a64Copy full SHA for 3902a64
demo03/README.md
@@ -0,0 +1,36 @@
1
+## Demo03 使用 `chunkhash`
2
+
3
+**`webpack` 配置文件中将 `[hash]` 替换为 `[chunkhash]`**
4
5
+```js
6
+// webpack.config.js
7
+module.exports = {
8
+ mode: 'production',
9
+ entry: {
10
+ index: './src/index.js',
11
+ },
12
+ output: {
13
+ path: path.join(__dirname, 'dist'),
14
+ filename: '[name]_[chunkhash:8].js',
15
16
+ optimization: {
17
+ runtimeChunk: true,
18
+ splitChunks: {
19
+ chunks: 'all'
20
21
22
+};
23
+```
24
25
+**打包结果 Output**
26
27
+> 见 dist 文件夹
28
29
+```zsh
30
+ Asset Size Chunks Chunk Names
31
+ index_201f4e93.js 168 bytes 0 [emitted] index
32
+runtime~index_2f124e9a.js 1.46 KiB 1 [emitted] runtime~index
33
+vendors~index_07bff0e7.js 69.7 KiB 2 [emitted] vendors~index
34
35
36
+打包后3个文件都带有不同的 `hash` 值。
0 commit comments