vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.51k stars 4.76k forks source link

[Bug report] personal theme set 'layouts/Layout.vue' to main field can not load index.styl #2178

Open yiliang114 opened 4 years ago

yiliang114 commented 4 years ago

Bug report

Steps to reproduce

you can see the package.json for my theme, if i just yarn start in local , maybe the package.json is not necessary. Thetheme/index.js in my theme is almost empty. And only do that as shown above, my theme can only to load index.styl automatically.

if i remove theme/index.js and set the "main" field to layouts/Layout.vue in package.json from the reference , after i run npm publish and install the latest theme, the style can not be load in the page.

What is expected?

set the "main" field to layouts/Layout.vue in package.json from the reference and publish my theme, people who installed the latest theme can load style correctly

What is actually happening?

theme may lose some style , due to the index.styl could not load automatically

Other relevant information

Environment Info:

System: OS: macOS Mojave 10.14.6 CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Binaries: Node: 10.15.2 - /usr/local/bin/node Yarn: 1.22.0 - ~/.yarn/bin/yarn npm: 6.9.0 - /usr/local/bin/npm Browsers: Chrome: 80.0.3987.100 Firefox: 71.0 Safari: 13.0.4 npmPackages: @vuepress/core: 1.3.0 @vuepress/theme-default: 1.3.0 vuepress: ^1.2.0 => 1.3.0 npmGlobalPackages: vuepress: 1.2.0

meteorlxy commented 4 years ago

Sorry but I cannot reproduce this issue. Please provide a "minimal" reproduce repo

yiliang114 commented 4 years ago

@meteorlxy I temporarily created a minimal reconstruction project link . You can just git clone it , then run npm install and npm start. when you open http://localhost:8080 , you can see a simple resume which like the following picture1. picture1

But In fact, normal performance is like picture2. picture2 image

After my screening the code, the only difference is the "main" field in package.json. I found only setting the "main" field "index.js" instead of "layouts/Layout.vue" (or other js file pathname) can make styles normally. But the official documentation said it could be "layouts/Layout.vue", I doubt that vuepress can not import styles/index.styl file automatically.

meteorlxy commented 4 years ago

Confirmed. That's an issue about resolving theme path.

Well, I personally decline 'layouts/Layout.vue' way, as it's mainly for compatibility with 0.x themes. That might be dropped in the future

meteorlxy commented 4 years ago

Figured out the reason. This issue was caused by #1564, which did not fix the corresponding issue correctly.