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

Styles are not loaded in the latest Nuxt #205

Open
yooneskh opened this issue Aug 2, 2023 · 7 comments
Open

Styles are not loaded in the latest Nuxt #205

yooneskh opened this issue Aug 2, 2023 · 7 comments
Labels

Comments

@yooneskh
Copy link

yooneskh commented Aug 2, 2023

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
Copy link
Owner

It might be upstream issue: unocss/unocss#2938

@yooneskh
Copy link
Author

yooneskh commented Aug 4, 2023

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
Copy link
Owner

jd-solanki commented Aug 9, 2023

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

Yes, #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 yooneskh closed this as completed Aug 9, 2023
@yooneskh
Copy link
Author

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
Copy link
Author

yooneskh commented Sep 9, 2023

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

@jd-solanki
Copy link
Owner

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
Copy link
Author

@jd-solanki oh happy holidays!

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

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

2 participants