vuepress / core

Vue-Powered Static Site Generator
https://vuepress.vuejs.org
MIT License
2.17k stars 922 forks source link

[Bug] User style does not have highest priority #1110

Open Mister-Hope opened 1 year ago

Mister-Hope commented 1 year ago

cc @meteorlxy The problem seems to be the one I once reported through WeChat.

technically speaking, plugin style may be loaded after theme, but user custom style file is loaded at the end of theme style, so plugin style might get a higher priority.

This may be something we should treat as a bug.

Originally posted by @Mister-Hope in https://github.com/vuepress/vuepress-next/discussions/1099#discussioncomment-3725817

Mister-Hope commented 1 year ago

Possible solution is extending core.

The core should accept a value related to user style, and it should inject it at last for bundler.

Mister-Hope commented 1 year ago

@meteorlxy Would like to have some discussion about how to fix this.

Techically, this is caused by https://github.com/vuepress/vuepress-next/blob/bcf6033ce2acf2b98dede4a4e580fe4f39222517/packages/core/src/app/createBaseApp.ts#L43-L46

My solution is adding a new filed in theme called userStyle, it can be a file path, package path or alias pointing to user file. (e.g.: for theme-default it will be '@vuepress/plugin-palette/style' as it's using palette plugin)

When we have a prepareUserStyle step at core, and style are imported at client/src/app.ts with import '@intermal/userStyle' after importing @internal/clientConfigs.

Besides, this also gives users ability to specific style (not palette or config) file they want to use.

Mister-Hope commented 1 year ago

Any suggestions with this one? If you agree I may open a pr.

Mister-Hope commented 1 year ago

Some other point of views.

After re-thinking, I relealize that "user style" is actually not much related to theme and plugins.

Theme and plugins can provide it's own config files for users, and users just need a place to add addtional style after theme and plugins style.

Under this point of view, we shall remove the concept "user style" from theme. amd move it to core.

Maybe provide a new field called style in user config and it's default point to .vuepress/styles/index.css?

Mister-Hope commented 1 year ago

Some other point of views.

After re-thinking, I relealize that "user style" is actually not much related to theme and plugins.

Theme and plugins can provide it's own config files for users, and users just need a place to add addtional style after theme and plugins style.

Under this point of view, we shall remove the concept "user style" from theme. amd move it to core.

Maybe provide a new field called style in user config and it's default point to .vuepress/styles/index.css?

@meteorlxy Could you share your points about this so that I can start doing something to fix this?

Mister-Hope commented 7 months ago

Bump here