fix: detect plugin without extension (#4579)

This commit is contained in:
Xin Du (Clark) 2018-12-18 14:19:38 +00:00 committed by Pooya Parsa
parent 2f0ed8571f
commit e7df65be1a
4 changed files with 8 additions and 1 deletions

View File

@ -123,7 +123,7 @@ export default class Builder {
resolvePlugins() {
// Check plugins exist then set alias to their real path
return Promise.all(this.plugins.map(async (p) => {
const ext = path.extname(p.src) ? '' : '{.+([^.]),/index.+([^.])}'
const ext = '{?(.+([^.])),/index.+([^.])}'
const pluginFiles = await glob(`${p.src}${ext}`)
if (!pluginFiles || pluginFiles.length === 0) {

View File

@ -37,6 +37,7 @@ export default {
extensions: 'ts',
plugins: [
'~/plugins/test',
'~/plugins/test.plugin',
{ src: '~/plugins/only-client.js', ssr: false }
],
loading: '~/components/loading',

View File

@ -0,0 +1,5 @@
if (process.client) {
window.__test_plugin_ext = true
} else {
global.__test_plugin_ext = true
}

View File

@ -90,6 +90,7 @@ describe('with-config', () => {
expect(html).toContain('<h1>I have custom configurations</h1>')
expect(window.__test_plugin).toBe(true)
expect(window.__test_plugin_ext).toBe(true)
})
test('/test/about (custom layout)', async () => {