mirror of
https://github.com/strapi/strapi.git
synced 2025-09-01 12:53:03 +00:00
Merge pull request #10868 from strapi/v4/plugin-api/local-plugin-loading
Append strapi.dir to plugin path if relative
This commit is contained in:
commit
52bc4642b8
@ -15,7 +15,7 @@ module.exports = ({ env }) => ({
|
||||
},
|
||||
myplugin: {
|
||||
enabled: true,
|
||||
resolve: `${__dirname}/../plugins/myplugin`,
|
||||
resolve: `./plugins/myplugin`, // From the root of the project
|
||||
config: {
|
||||
testConf: 3,
|
||||
},
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { dirname, join } = require('path');
|
||||
const { dirname, join, resolve } = require('path');
|
||||
const { statSync, existsSync } = require('fs');
|
||||
const _ = require('lodash');
|
||||
const { get, has, pick, pickBy, defaultsDeep, map, prop, pipe } = require('lodash/fp');
|
||||
@ -29,9 +29,9 @@ const toDetailedDeclaration = declaration => {
|
||||
try {
|
||||
pathToPlugin = dirname(require.resolve(declaration.resolve));
|
||||
} catch (e) {
|
||||
if (existsSync(declaration.resolve) && statSync(declaration.resolve).isDirectory()) {
|
||||
pathToPlugin = declaration.resolve;
|
||||
} else {
|
||||
pathToPlugin = resolve(strapi.dir, declaration.resolve);
|
||||
|
||||
if (!existsSync(pathToPlugin) || !statSync(pathToPlugin).isDirectory()) {
|
||||
throw new Error(`${declaration.resolve} couldn't be resolved`);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user