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

Border (and maybe other) styles not working when vite builds in library mode #2285

Closed
4 tasks done
HiggsWRX opened this issue Mar 1, 2023 · 4 comments
Closed
4 tasks done
Labels

Comments

@HiggsWRX
Copy link

HiggsWRX commented Mar 1, 2023

UnoCSS version

0.50.2

Describe the bug

I'm building a standalone component library for my company, and in it I'm using unocss of course.
After building and packing, and importing it as a standalone package in another repository, everything works kind of like expected but some properties refuse to work. I can see they are correctly exported in the css file but they're just not being applied for some reason.

In this specific case, the border property is the one being ignored. Everything else styles correctly, font-sans, margins, etc...

I have tried this in a brand new project without anything else installed, so no other unocss or styling packages that could conflict.

Reproduction

Not sure how to reproduce in playground since this involves building the project in library mode and then importing it from another as a package

System Info

MacOS, tested on every browser, React 18

Validations

@HiggsWRX
Copy link
Author

HiggsWRX commented Mar 1, 2023

It seems explicitly adding 'border-solid' to the classes list fixes the issue for now

@sherif414
Copy link

I remember not having to explicitly set border-solid few months ago but now it's required.
Maybe it was changed in recent versions?

@sibbng
Copy link
Member

sibbng commented Mar 2, 2023

Yes it is removed in #1971.

If you don't want to add b-solid on every occurrence of border utilities, maybe this code would help:

Playground

export default defineConfig({
  variants: [
    {
      match(input) {
        const match = input.match(/^(?:border|b)()(?:-(.+))?$/)
        if (match) {
          return {
            matcher: input,
            handle: (input, next) => {
              if (input.entries[0]?.[0] === 'border-width') {
                return next({
                  ...input,
                  entries: [...input.entries, ['border-style', 'solid']],
                })
              }
            },
          }
        }
      },
    },
  ],
  presets: [
    presetUno(),
    presetAttributify(),
  ]
})

I'm not sure if this has some edge cases or not. @chu121su12 is better at this stuff than me.

Let me know if you encounter any issues.

@stale
Copy link

stale bot commented May 1, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 1, 2023
@antfu antfu closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants