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

Working With Nuxt 3 Module #197

Open
halilyuce opened this issue Jan 30, 2023 · 0 comments
Open

Working With Nuxt 3 Module #197

halilyuce opened this issue Jan 30, 2023 · 0 comments

Comments

@halilyuce
Copy link

halilyuce commented Jan 30, 2023

Describe the bug

I created a UI module that contains components and although everything looks as it should in the development env but when I build the project, I noticed that the windiCSS classes were not created.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Nuxt 3 module project
  2. Add WindiCSS to the project
  3. Build the project
  4. See the error

Expected behavior
After compiling the project, I was expecting to see the CSS classes I used in the components.

Screenshots

When I add the component from the nuxt module I created to another simple Nuxt 3 project:

image

When I did run the module project in dev mode:

image

Additional context

nuxt.config.ts

import { defineNuxtConfig } from "nuxt/config";
import module from "../src/module";

export default defineNuxtConfig({
  modules: [module, "nuxt-windicss"],
  ssr: false,
  imports: {
    autoImport: true,
  },
  windicss: {
    scan: {
      include: ["../src/runtime/**/*.{vue,ts}"],
      exclude: ["node_modules", ".git"],
    },
  },
  css: ["ant-design-vue/dist/antd.css"],
});


module.ts

async setup(options, nuxt) {
    if (options.addPlugin) {
      const { resolve } = createResolver(import.meta.url);
      const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
      nuxt.options.build.transpile.push(runtimeDir);

      addImportsDir(resolve(runtimeDir, "composables"));

      addComponentsDir({
        path: resolve(runtimeDir, "components"),
        pathPrefix: false,
        prefix: "",
        // @ts-ignore
        level: 999,
        global: true,
      });

      addPlugin(resolve(runtimeDir, "plugin"));
    }
  },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant