fix(webpack): normalize devtool for terser compatibility (#6566)

This commit is contained in:
Xin Du (Clark) 2019-10-19 09:21:42 +01:00 committed by Pooya Parsa
parent 257ae2279b
commit 8391753484
2 changed files with 10 additions and 5 deletions

View File

@ -439,11 +439,16 @@ export default class WebpackBaseConfig {
if (typeof extend === 'function') {
const extendedConfig = extend.call(
this.builder, config, { loaders: this.loaders, ...this.nuxtEnv }
)
// Only overwrite config when something is returned for backwards compatibility
if (extendedConfig !== undefined) {
return extendedConfig
) || config
const pragma = /@|#/
const { devtool } = extendedConfig
if (typeof devtool === 'string' && pragma.test(devtool)) {
extendedConfig.devtool = devtool.replace(pragma, '')
consola.warn(`devtool has been normalized to ${extendedConfig.devtool} as webpack documented value`)
}
return extendedConfig
}
return config
}

View File

@ -86,7 +86,7 @@ export default {
transpile: 'vue-test',
extend (config, options) {
return Object.assign({}, config, {
devtool: '#source-map'
devtool: 'source-map'
})
}
},