mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
perf(webpack): prefer using contenthash
(#6632)
This commit is contained in:
parent
0980dad778
commit
4f0aa74ef2
@ -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) {
|
||||
|
@ -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: {},
|
||||
|
@ -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', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user