mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
refactor: warnfix plugin
This commit is contained in:
parent
81bb278305
commit
9f72e4a6e2
@ -74,7 +74,7 @@ export default class Builder {
|
||||
return {
|
||||
src: this.nuxt.resolvePath(p.src),
|
||||
ssr: (p.ssr !== false),
|
||||
name: basename(p.src, extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_' + hash(p.src)
|
||||
name: basename(p.src, 'nuxt_plugin_' + extname(p.src)).replace(/[^a-zA-Z?\d\s:]/g, '') + '_' + hash(p.src)
|
||||
}
|
||||
}), p => p.name)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import { join, resolve } from 'path'
|
||||
import webpack from 'webpack'
|
||||
import { isUrl, urlJoin } from 'utils'
|
||||
import TimeFixPlugin from './timefix-plugin'
|
||||
import WarnFixPlugin from './warnfix-plugin'
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -110,6 +111,9 @@ export default function webpackBaseConfig(name) {
|
||||
config.plugins.unshift(new TimeFixPlugin())
|
||||
}
|
||||
|
||||
// Hide warnings about plugins without a default export (#1179)
|
||||
config.plugins.push(new WarnFixPlugin())
|
||||
|
||||
// CSS extraction
|
||||
const extractCSS = this.options.build.extractCSS
|
||||
if (extractCSS) {
|
||||
@ -120,21 +124,6 @@ export default function webpackBaseConfig(name) {
|
||||
config.plugins.push(new ExtractTextPlugin(extractOptions))
|
||||
}
|
||||
|
||||
// Workaround for hiding Warnings about plugins without a default export (#1179)
|
||||
/* istanbul ignore next */
|
||||
config.plugins.push({
|
||||
apply(compiler) {
|
||||
compiler.plugin('done', stats => {
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter(warn => {
|
||||
if (warn.name === 'ModuleDependencyWarning' && warn.message.includes(`export 'default'`) && warn.message.includes('plugin')) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// --------------------------------------
|
||||
// Dev specific config
|
||||
// --------------------------------------
|
||||
|
15
lib/builder/webpack/warnfix-plugin.js
Normal file
15
lib/builder/webpack/warnfix-plugin.js
Normal file
@ -0,0 +1,15 @@
|
||||
export default class WarnFixPlugin {
|
||||
apply(compiler) {
|
||||
compiler.plugin('done', stats => {
|
||||
stats.compilation.warnings = stats.compilation.warnings.filter(warn => {
|
||||
/* istanbul ignore next */
|
||||
if (warn.name === 'ModuleDependencyWarning' &&
|
||||
warn.message.includes(`export 'default'`) &&
|
||||
warn.message.indexOf('nuxt_plugin_') === 0) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user