Repository: nuxt/nuxt.js
Pull request #6632 (2019-10-29 17:04:12)

perf(webpack): prefer using `contenthash`
## Types of changes
- [ ] Bug fix (a non-breaking change which fixes an issue)
- [x] New feature (a non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Description
`[contenthash]` is a better way of identifying a file if the contents don't change. See issues: https://github.com/webpack/webpack.js.org/issues/2096 and https://github.com/webpack/webpack/issues/7138.

This should mean that assets (like images or fonts) that are unlikely to change between deploys can be cached more efficiently.

## Checklist:
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly. PR: https://github.com/nuxt/docs/pull/1710
- [x] I have added tests to cover my changes (if not applicable, please state why)
- [x] All new and existing tests are passing.



clarkdo: Was changed from `contenthash` to `chunkhash` 1 year ago https://github.com/nuxt/nuxt.js/pull/3789#discussion_r212083097, sorry that I can't recall all the details, @pi0 do you have any idea ?

Patch:
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index fbf73938c..000000000
--- a/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,23 +0,0 @@
-<!--
-🚨 IMPORTANT 🚨
-
-Please use the following link to create a new issue:
-
-- 🚨 Bug report - https://bug.nuxtjs.org/ 
-- 🙋 Feature request - https://feature.nuxtjs.org/ 
-- 🤔 Help wanted - https://otechie.com/nuxt 
-- ❗️ All other issues - https://cmty.nuxtjs.org/ 
-
-If your issue was not created using the app above, **it will be closed immediately**.
-
-🚨 注意事项 🚨
-
-请务必使用下述链接来创建 issue:
-
-- 🚨 Bug 提交 - https://bug.nuxtjs.org/ 
-- 🙋 新功能提案 - https://feature.nuxtjs.org/ 
-- 🤔 寻求帮助 - https://otechie.com/nuxt 
-- ❗️ 其他问题 - https://cmty.nuxtjs.org/ 
-
-如果 issue 不是通过上述链接进行创建， **该 issue 会被系统自动关闭**
--->
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 000000000..644249f24
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,14 @@
+blank_issues_enabled: false
+contact_links:
+  - name: 🚨 Bug report
+    url: https://bug.nuxtjs.org/
+    about: Please report bugs here.
+  - name: 🙋 Feature request
+    url: https://feature.nuxtjs.org/
+    about: Please request features here.
+  - name: 🤔 Consulting from the Nuxt team
+    url: https://otechie.com/nuxt
+    about: Get technical support, project audits, app deployments, and custom development from the core Nuxt.js team.
+  - name: ❗️ All other issues
+    url: https://cmty.nuxtjs.org/
+    about: Please create all other issues here.
diff --git a/examples/custom-build/nuxt.config.js b/examples/custom-build/nuxt.config.js
index 92e66f67c..b2f4edb18 100644
--- a/examples/custom-build/nuxt.config.js
+++ b/examples/custom-build/nuxt.config.js
@@ -1,9 +1,9 @@
 export default {
   build: {
     filenames: {
-      css: 'styles.[chunkhash].css', // default: common.[chunkhash].css
-      manifest: 'manifest.[hash].js', // default: manifest.[hash].js
-      app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js
+      css: 'styles.[contenthash].css', // default: common.[contenthash].css
+      manifest: 'manifest.[contenthash].js', // default: manifest.[contenthash].js
+      app: 'app.[contenthash].js' // default: nuxt.bundle.[contenthash].js
     },
     extend (config, { isDev }) {
       if (isDev) {
diff --git a/packages/config/src/config/build.js b/packages/config/src/config/build.js
index c0c5eaa42..d19a7a0ce 100644
--- a/packages/config/src/config/build.js
+++ b/packages/config/src/config/build.js
@@ -19,12 +19,12 @@ export default () => ({
   publicPath: '/_nuxt/',
   filenames: {
     // { isDev, isClient, isServer }
-    app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[chunkhash].js',
-    chunk: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[chunkhash].js',
+    app: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js',
+    chunk: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js',
     css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
-    img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
-    font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
-    video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
+    img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[contenthash:7].[ext]',
+    font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[contenthash:7].[ext]',
+    video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[contenthash:7].[ext]'
   },
   loaders: {
     file: {},


Test patch:
diff --git a/packages/config/test/config/build.test.js b/packages/config/test/config/build.test.js
index accec320e..f55f79e6e 100644
--- a/packages/config/test/config/build.test.js
+++ b/packages/config/test/config/build.test.js
@@ -15,12 +15,12 @@ describe('config: build', () => {
   test('should return prod filenames', () => {
     const { filenames } = buildConfig()
     const env = { isDev: false }
-    expect(filenames.app(env)).toEqual('[chunkhash].js')
-    expect(filenames.chunk(env)).toEqual('[chunkhash].js')
+    expect(filenames.app(env)).toEqual('[contenthash].js')
+    expect(filenames.chunk(env)).toEqual('[contenthash].js')
     expect(filenames.css(env)).toEqual('[contenthash].css')
-    expect(filenames.img(env)).toEqual('img/[hash:7].[ext]')
-    expect(filenames.font(env)).toEqual('fonts/[hash:7].[ext]')
-    expect(filenames.video(env)).toEqual('videos/[hash:7].[ext]')
+    expect(filenames.img(env)).toEqual('img/[contenthash:7].[ext]')
+    expect(filenames.font(env)).toEqual('fonts/[contenthash:7].[ext]')
+    expect(filenames.video(env)).toEqual('videos/[contenthash:7].[ext]')
   })
 
   test('should return modern filenames', () => {