Use getFilename for url-loader assets (#3759)

Now they get [name] removed in production.
This commit is contained in:
Tatsuyuki Ishi 2018-08-18 18:00:35 +09:00 committed by Clark Du
parent 432720b8c8
commit 715df92eac
2 changed files with 8 additions and 5 deletions

View File

@ -49,7 +49,7 @@ export default class WebpackBaseConfig {
// Don't use hashes when watching
// https://github.com/webpack/webpack/issues/1914#issuecomment-174171709
if (this.options.dev) {
fileName = fileName.replace(/\[(chunkhash|contenthash|hash)\]\./g, '')
fileName = fileName.replace(/\[(chunkhash|contenthash|hash)(?::(\d+))?\]\./g, '')
}
// Don't use [name] for production assets
@ -185,7 +185,7 @@ export default class WebpackBaseConfig {
loader: 'url-loader',
options: {
limit: 1000, // 1KO
name: 'img/[name].[hash:7].[ext]'
name: this.getFileName('img')
}
})
},
@ -195,7 +195,7 @@ export default class WebpackBaseConfig {
loader: 'url-loader',
options: {
limit: 1000, // 1 KO
name: 'fonts/[name].[hash:7].[ext]'
name: this.getFileName('font')
}
})
},
@ -204,7 +204,7 @@ export default class WebpackBaseConfig {
use: perfLoader.pool('assets', {
loader: 'file-loader',
options: {
name: 'videos/[name].[hash:7].[ext]'
name: this.getFileName('video')
}
})
}

View File

@ -53,7 +53,10 @@ export default {
filenames: {
app: '[name].[contenthash].js',
chunk: '[name].[contenthash].js',
css: '[name].[contenthash].css'
css: '[name].[contenthash].css',
img: 'img/[name].[hash:7].[ext]',
font: 'fonts/[name].[hash:7].[ext]',
video: 'videos/[name].[hash:7].[ext]'
},
styleResources: {},
plugins: [],