Skip to content

Commit

Permalink
fix(webpack): normalize devtool for terser compatibility (#6566)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and pi0 committed Oct 19, 2019
1 parent 257ae22 commit 8391753
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions packages/webpack/src/config/base.js
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/with-config/nuxt.config.js
Expand Up @@ -86,7 +86,7 @@ export default {
transpile: 'vue-test',
extend (config, options) {
return Object.assign({}, config, {
devtool: '#source-map'
devtool: 'source-map'
})
}
},
Expand Down

0 comments on commit 8391753

Please sign in to comment.