core icon indicating copy to clipboard operation
core copied to clipboard

[Bug] User style does not have highest priority

Open Mister-Hope opened this issue 3 years ago • 6 comments

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 avatar Sep 29 '22 10:09 Mister-Hope

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 avatar Sep 29 '22 10:09 Mister-Hope

@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 avatar Oct 18 '22 05:10 Mister-Hope

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

Mister-Hope avatar Nov 21 '22 10:11 Mister-Hope

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 avatar Dec 09 '22 13:12 Mister-Hope

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 avatar Apr 21 '23 06:04 Mister-Hope

Bump here

Mister-Hope avatar Nov 20 '23 09:11 Mister-Hope