mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix: detect plugin without extension (#4579)
This commit is contained in:
parent
2f0ed8571f
commit
e7df65be1a
@ -123,7 +123,7 @@ export default class Builder {
|
|||||||
resolvePlugins() {
|
resolvePlugins() {
|
||||||
// Check plugins exist then set alias to their real path
|
// Check plugins exist then set alias to their real path
|
||||||
return Promise.all(this.plugins.map(async (p) => {
|
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}`)
|
const pluginFiles = await glob(`${p.src}${ext}`)
|
||||||
|
|
||||||
if (!pluginFiles || pluginFiles.length === 0) {
|
if (!pluginFiles || pluginFiles.length === 0) {
|
||||||
|
1
test/fixtures/with-config/nuxt.config.js
vendored
1
test/fixtures/with-config/nuxt.config.js
vendored
@ -37,6 +37,7 @@ export default {
|
|||||||
extensions: 'ts',
|
extensions: 'ts',
|
||||||
plugins: [
|
plugins: [
|
||||||
'~/plugins/test',
|
'~/plugins/test',
|
||||||
|
'~/plugins/test.plugin',
|
||||||
{ src: '~/plugins/only-client.js', ssr: false }
|
{ src: '~/plugins/only-client.js', ssr: false }
|
||||||
],
|
],
|
||||||
loading: '~/components/loading',
|
loading: '~/components/loading',
|
||||||
|
5
test/fixtures/with-config/plugins/test.plugin.js
vendored
Normal file
5
test/fixtures/with-config/plugins/test.plugin.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
if (process.client) {
|
||||||
|
window.__test_plugin_ext = true
|
||||||
|
} else {
|
||||||
|
global.__test_plugin_ext = true
|
||||||
|
}
|
@ -90,6 +90,7 @@ describe('with-config', () => {
|
|||||||
expect(html).toContain('<h1>I have custom configurations</h1>')
|
expect(html).toContain('<h1>I have custom configurations</h1>')
|
||||||
|
|
||||||
expect(window.__test_plugin).toBe(true)
|
expect(window.__test_plugin).toBe(true)
|
||||||
|
expect(window.__test_plugin_ext).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/test/about (custom layout)', async () => {
|
test('/test/about (custom layout)', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user