jd-solanki / anu

Anu - DX focused utility based vue component library built on top of UnoCSS & VueUse ⚡️🔥
https://anu-vue.netlify.app/
MIT License
1.04k stars 56 forks source link

Styles are not loaded in the latest Nuxt #205

Open yooneskh opened 1 year ago

yooneskh commented 1 year ago

Hello and thank you very much for you great work!

I just set up a minimal Nuxt project with anu but noticed the styles aren't being loaded. This is the reproduction project https://github.com/yooneskh/repro-anu-nuxt

Is there anything wrong in it?

jd-solanki commented 1 year ago

It might be upstream issue: https://github.com/unocss/unocss/issues/2938

yooneskh commented 1 year ago

This is resolved in the upstream now. It was related to Nuxt. Removing the lock file so the package manager would get the latest packages will fix the issues.

An unrelated question, do you know if Unocss or Nuxt can generate only the necessary css for each page? So the css code for Btn (for example) which is not used in the current page but is used in the other pages will not be loaded?

jd-solanki commented 1 year ago

Unocss or Nuxt can generate only the necessary css for each page

Yes, https://github.com/jd-solanki/anu/issues/197

When btn will be used for the first time, UnoCSS will only load the style at that time

If you don't get this behavior let me know.

yooneskh commented 1 year ago

Ok so i made a barebones project to test this. You can find it here. https://github.com/yooneskh/repro-anu-nuxt (It is different than the one above)

It is basically these files.

// nuxt.config.js

export default defineNuxtConfig({
  vue: {
    defineModel: true,
  },
  modules: [
    '@anu-vue/nuxt',
    '@unocss/nuxt',
  ],
});

// uno.config.js

import { defineConfig } from 'unocss';

export default defineConfig({
  include: [
    /.*\/anu-vue\.js(.*)?$/,
    './**/*.vue',
    './**/*.md',
  ],
});
// app.vue

<script setup>

</script>

<template>
  <nuxt-page />
</template>

// pages/index.vue

<script setup>

</script>

<template>
  <p>Hello</p>
</template>

You can view it live here https://repro-anu-nuxt.vercel.app/

The important issue is that both the styles and the js bundle for all components are loaded. You can view its source, but basically, in this js bundle https://repro-anu-nuxt.vercel.app/_nuxt/entry.6f577059.js you can find all components (try searching for "ABtn" and "AList" and so on), and in this css bundle https://repro-anu-nuxt.vercel.app/_nuxt/entry.de0e007d.css you can find styles for all components.

Note that this happens while nothing is used.

Do you have any idea on what's wrong?

yooneskh commented 1 year ago

Hi there @jd-solanki sorry to ping you, did you have the time to look at this?

jd-solanki commented 1 year ago

Sorry @yooneskh I was on holidays was busy with other things lately. I'm planning to move to Python community in near future. However, I'll try to resolve this issue and pending issue for sure 👍🏻

Maybe in next two week I'll be able to resolve this.

Thanks for your interest. Would like to contribute to this? We can move this repo to org for others to contribute.

yooneskh commented 1 year ago

@jd-solanki oh happy holidays!

Sure i will love to contribute. I have lots of ideas to improve anu.