mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
fix(webpack): don't use hashes when watching
helps preventing memory leaks on dev mode and more clear source
This commit is contained in:
parent
f99897376b
commit
b86426aaa0
@ -204,6 +204,18 @@ export default class Builder {
|
||||
return options
|
||||
}
|
||||
|
||||
getFileName(name) {
|
||||
let fileName = this.options.build.filenames[name]
|
||||
|
||||
// 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, '')
|
||||
}
|
||||
|
||||
return fileName
|
||||
}
|
||||
|
||||
async generateRoutesAndFiles() {
|
||||
debug('Generating files...')
|
||||
// -- Templates --
|
||||
|
@ -25,8 +25,8 @@ export default function webpackBaseConfig({ name, isServer }) {
|
||||
},
|
||||
output: {
|
||||
path: resolve(this.options.buildDir, 'dist'),
|
||||
filename: this.options.build.filenames.app,
|
||||
chunkFilename: this.options.build.filenames.chunk,
|
||||
filename: this.getFileName('app'),
|
||||
chunkFilename: this.getFileName('chunk'),
|
||||
publicPath: (isUrl(this.options.build.publicPath)
|
||||
? this.options.build.publicPath
|
||||
: urlJoin(this.options.router.base, this.options.build.publicPath))
|
||||
@ -118,7 +118,7 @@ export default function webpackBaseConfig({ name, isServer }) {
|
||||
const extractCSS = this.options.build.extractCSS
|
||||
if (extractCSS) {
|
||||
const extractOptions = Object.assign(
|
||||
{ filename: this.options.build.filenames.css },
|
||||
{ filename: this.getFileName('css') },
|
||||
typeof extractCSS === 'object' ? extractCSS : {}
|
||||
)
|
||||
config.plugins.push(new ExtractTextPlugin(extractOptions))
|
||||
|
@ -73,7 +73,7 @@ export default function webpackClientConfig() {
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'manifest',
|
||||
minChunks: Infinity,
|
||||
filename: this.options.build.filenames.manifest
|
||||
filename: this.getFileName('manifest')
|
||||
})
|
||||
)
|
||||
|
||||
@ -200,7 +200,7 @@ function commonChunksPlugin(config) {
|
||||
config.plugins.unshift(
|
||||
new webpack.optimize.CommonsChunkPlugin({
|
||||
name: 'vendor',
|
||||
filename: this.options.build.filenames.vendor,
|
||||
filename: this.getFileName('vendor'),
|
||||
minChunks(module, count) {
|
||||
// Detect and externalize well-known vendor if detected
|
||||
if (module.context && maybeVendor.some(v => module.context.includes(v))) {
|
||||
|
Loading…
Reference in New Issue
Block a user