Catch cryptic error when a plugin is not found

This commit is contained in:
John Fischer 2017-10-14 19:33:26 +02:00 committed by Pooya Parsa
parent f5acb6fc0e
commit 5d3156c0c7

View File

@ -5,7 +5,7 @@ import hash from 'hash-sum'
import pify from 'pify'
import webpack from 'webpack'
import serialize from 'serialize-javascript'
import { join, resolve, basename, dirname } from 'path'
import { join, resolve, basename, extname, dirname } from 'path'
import Tapable from 'tappable'
import MFS from 'memory-fs'
import webpackDevMiddleware from 'webpack-dev-middleware'
@ -62,8 +62,11 @@ export default class Builder extends Tapable {
get plugins () {
return this.options.plugins.map((p, i) => {
if (typeof p === 'string') p = { src: p }
p.src = this.nuxt.resolvePath(p.src)
return { src: p.src, ssr: (p.ssr !== false), name: `plugin${i}` }
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, '')
}
})
}