feat(core): allow plugin lifecycles to return relative paths (#6921)

* feat(core): resolve plugin lifecycles returning relative paths

* fix typo

* fix tests

* revert

* rename path -> entryPath
This commit is contained in:
Joshua Chen 2022-03-16 20:47:15 +08:00 committed by GitHub
parent 8d1c1954c1
commit 68aaf9201f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 100 additions and 68 deletions

View file

@ -61,7 +61,7 @@ module.exports = function (context, options) {
## `getThemePath()` {#getThemePath}
Returns the path to the directory where the theme components can be found. When your users call `swizzle`, `getThemePath` is called and its returned path is used to find your theme components.
Returns the path to the directory where the theme components can be found. When your users call `swizzle`, `getThemePath` is called and its returned path is used to find your theme components. Relative paths are resolved against the folder containing the entry point.
For example, your `getThemePath` can be:
@ -73,7 +73,7 @@ module.exports = function (context, options) {
name: 'my-theme',
// highlight-start
getThemePath() {
return path.resolve(__dirname, './theme');
return './theme';
},
// highlight-end
};
@ -103,11 +103,11 @@ module.exports = function (context, options) {
// highlight-start
getThemePath() {
// Where compiled JavaScript output lives
return path.join(__dirname, '../lib/theme');
return '../lib/theme';
},
getTypeScriptThemePath() {
// Where TypeScript source code lives
return path.resolve(__dirname, '../src/theme');
return '../src/theme';
},
// highlight-end
};