Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The index.js within themes is ignored during the build process #942

Closed
sebiniemann opened this issue Oct 17, 2018 · 6 comments
Closed

The index.js within themes is ignored during the build process #942

sebiniemann opened this issue Oct 17, 2018 · 6 comments
Labels
status: awaiting more context Need more context about this issue

Comments

@sebiniemann
Copy link

Bug report

Version

1.0.0-alpha.12

Steps to reproduce

Add the following index.js to a theme:

process.exit(1);

What is expected?

The built process should fail with exit code 1, proving that index.js was called.

What is actually happening?

The built process is successful, fully ignoring the index.js and therefore any options within it (esp. plugins).

Other relevant information

Compared to #928, the theme is included by simply stating its file path, instead of a dependency package

@sebiniemann sebiniemann changed the title The index.js within themes is ignored during the built process The index.js within themes is ignored during the build process Oct 17, 2018
@ulivz
Copy link
Member

ulivz commented Oct 17, 2018

Cannot reproduce it, could you provide more info?

  • Your laptop's version
  • local theme or a theme from dep

@ulivz ulivz added the status: awaiting more context Need more context about this issue label Oct 17, 2018
@sebiniemann
Copy link
Author

sebiniemann commented Oct 17, 2018

I just created a reproduction repo to demonstrate it: https://github.com/SebastianNiemann/vuepress-issue-942

Within this, I am using a local theme. The reason is just that I found it easier to observe whether VuePress is loading index.js's configuration or not by using process.exit(1);, avoiding invocations by require.resolve during resolveModule if I would have used a theme from a dep instead.

Not sure what you meant by laptop's version, but if it is about the OS, I observed this under Windows 10.

@ulivz
Copy link
Member

ulivz commented Oct 21, 2018

Maybe you should read the docs carefully, you just used a way that we didn't mention in the documentation.

Move the theme directory to .vuepress directory instead.

See: Directory Structure.

@ulivz ulivz closed this as completed Oct 21, 2018
@sebiniemann
Copy link
Author

sebiniemann commented Oct 21, 2018

Understood.

Just to give a little bit reasoning how we got here into the first place:

We actually use absolute paths as theme directories within our projects (especially since everything works fine, despite this index.js issue), in cases where multiple sites use the same theme and everything is placed in the same project, avoiding kill process && yarn upgrade && yarn serve to reload changes in the theme during development.

However, it seemed that our understanding about the theme config option (https://vuepress.vuejs.org/config/#theme) came from an unclear understanding whether paths would be acceptable, especially since they worked flawless before.

To make sure, we looked into the source (currently at @vuepress/core/lib/prepare/loadTheme.js) where the source documentation of loadTheme states:

 * Resolve theme.
 *
 *   Resolving Priority:
 *
 *   1. If the theme was a absolute path and that path exists, respect it
 *      as the theme directory.
 *   2. If 'theme' directory located at vuepressDir exists, respect it as
 *      the theme directory.
 *   3. If 'theme' was a shortcut string, resolve it from deps.

Given that the top priority was to resolve absolute paths as theme paths (and all the code within loadTheme to support this), we where unfortunately under the impression that paths where (already?) supported. However, this was just meant to share our experience, no biggie.


@ulivz Having all that said, I would like to suggest a more specific documentation on the theme option (especially since try&error would suggest that paths are supported), or even more happily volunteer to fully support absolute paths as theme directories 😃

@ulivz
Copy link
Member

ulivz commented Oct 22, 2018

Thanks for pointing out the unsharpness, for now the documentation are still WIP, and after I closed this issue, I also took some time to rewrite the module resolver at 80cb1d5, for now the absolute and relative path are both well supported,but I need some time to refine the documentation.

@sebiniemann
Copy link
Author

Awesome 🎉 This helps a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting more context Need more context about this issue
Projects
None yet
Development

No branches or pull requests

2 participants