perf(webpack): prefer using contenthash (#6632)

This commit is contained in:
Daniel Roe 2019-10-29 18:06:14 +00:00 committed by Pooya Parsa
parent 0980dad778
commit 4f0aa74ef2
3 changed files with 13 additions and 13 deletions

View File

@ -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) {

View File

@ -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: {},

View File

@ -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', () => {