diff --git a/examples/getstarted/config/plugins.js b/examples/getstarted/config/plugins.js index 301ee51da4..5aae0b4a8e 100644 --- a/examples/getstarted/config/plugins.js +++ b/examples/getstarted/config/plugins.js @@ -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, }, diff --git a/packages/core/strapi/lib/core/loaders/plugins/get-enabled-plugins.js b/packages/core/strapi/lib/core/loaders/plugins/get-enabled-plugins.js index c28851b478..67ecf52b5d 100644 --- a/packages/core/strapi/lib/core/loaders/plugins/get-enabled-plugins.js +++ b/packages/core/strapi/lib/core/loaders/plugins/get-enabled-plugins.js @@ -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`); } }