mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 14:41:25 +00:00
perf(webpack): prefer using contenthash
(#6632)
This commit is contained in:
parent
0980dad778
commit
4f0aa74ef2
@ -1,9 +1,9 @@
|
|||||||
export default {
|
export default {
|
||||||
build: {
|
build: {
|
||||||
filenames: {
|
filenames: {
|
||||||
css: 'styles.[chunkhash].css', // default: common.[chunkhash].css
|
css: 'styles.[contenthash].css', // default: common.[contenthash].css
|
||||||
manifest: 'manifest.[hash].js', // default: manifest.[hash].js
|
manifest: 'manifest.[contenthash].js', // default: manifest.[contenthash].js
|
||||||
app: 'app.[chunkhash].js' // default: nuxt.bundle.[chunkhash].js
|
app: 'app.[contenthash].js' // default: nuxt.bundle.[contenthash].js
|
||||||
},
|
},
|
||||||
extend (config, { isDev }) {
|
extend (config, { isDev }) {
|
||||||
if (isDev) {
|
if (isDev) {
|
||||||
|
@ -19,12 +19,12 @@ export default () => ({
|
|||||||
publicPath: '/_nuxt/',
|
publicPath: '/_nuxt/',
|
||||||
filenames: {
|
filenames: {
|
||||||
// { isDev, isClient, isServer }
|
// { isDev, isClient, isServer }
|
||||||
app: ({ 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` : '[chunkhash].js',
|
chunk: ({ isDev, isModern }) => isDev ? `${isModern ? 'modern-' : ''}[name].js` : '[contenthash].js',
|
||||||
css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
|
css: ({ isDev }) => isDev ? '[name].css' : '[contenthash].css',
|
||||||
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[hash:7].[ext]',
|
img: ({ isDev }) => isDev ? '[path][name].[ext]' : 'img/[contenthash:7].[ext]',
|
||||||
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[hash:7].[ext]',
|
font: ({ isDev }) => isDev ? '[path][name].[ext]' : 'fonts/[contenthash:7].[ext]',
|
||||||
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[hash:7].[ext]'
|
video: ({ isDev }) => isDev ? '[path][name].[ext]' : 'videos/[contenthash:7].[ext]'
|
||||||
},
|
},
|
||||||
loaders: {
|
loaders: {
|
||||||
file: {},
|
file: {},
|
||||||
|
@ -15,12 +15,12 @@ describe('config: build', () => {
|
|||||||
test('should return prod filenames', () => {
|
test('should return prod filenames', () => {
|
||||||
const { filenames } = buildConfig()
|
const { filenames } = buildConfig()
|
||||||
const env = { isDev: false }
|
const env = { isDev: false }
|
||||||
expect(filenames.app(env)).toEqual('[chunkhash].js')
|
expect(filenames.app(env)).toEqual('[contenthash].js')
|
||||||
expect(filenames.chunk(env)).toEqual('[chunkhash].js')
|
expect(filenames.chunk(env)).toEqual('[contenthash].js')
|
||||||
expect(filenames.css(env)).toEqual('[contenthash].css')
|
expect(filenames.css(env)).toEqual('[contenthash].css')
|
||||||
expect(filenames.img(env)).toEqual('img/[hash:7].[ext]')
|
expect(filenames.img(env)).toEqual('img/[contenthash:7].[ext]')
|
||||||
expect(filenames.font(env)).toEqual('fonts/[hash:7].[ext]')
|
expect(filenames.font(env)).toEqual('fonts/[contenthash:7].[ext]')
|
||||||
expect(filenames.video(env)).toEqual('videos/[hash:7].[ext]')
|
expect(filenames.video(env)).toEqual('videos/[contenthash:7].[ext]')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should return modern filenames', () => {
|
test('should return modern filenames', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user