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

Vite + UniApp Build Error #1999

Closed
ModyQyW opened this issue Dec 14, 2022 · 8 comments
Closed

Vite + UniApp Build Error #1999

ModyQyW opened this issue Dec 14, 2022 · 8 comments

Comments

@ModyQyW
Copy link

ModyQyW commented Dec 14, 2022

Hi. I am facing problems when I am using vite, uni-app and unocss.

npx degit dcloudio/uni-preset-vue#vite-ts playground
cd playground
echo 'shamefully-hoist=true' > .npmrc
npx @dcloudio/uvm alpha # choose pnpm here
pnpm install unocss -D
// unocss.config.ts
import { defineConfig } from "unocss";

export default defineConfig({
  presets: [],
});
// src/main.ts
import { createSSRApp } from "vue";
import App from "./App.vue";
import "uno.css";
export function createApp() {
  const app = createSSRApp(App);
  return {
    app,
  };
}
// vite.config.ts
import { defineConfig } from "vite";
import unocss from "unocss/vite";
import uni from "@dcloudio/vite-plugin-uni";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [unocss(), uni()],
});
pnpm run dev:mp-weixin

There should be a dist/dev/mp-weixin/app.wxss. But I get dist/dev/mp-weixin/app.css.

image

➜  [playground] node -v                
v18.12.0
➜  [playground] npm -v                                            
9.2.0
➜  [playground] pnpm -v           
7.18.2

With unocss@0.46.5, everything is fine. But with unocss@0.47, app.wxss is missing.

Is it a expected behavior? If so, how can I get app.wxss back? Thanks.

@sibbng
Copy link
Member

sibbng commented Dec 14, 2022

Could be related to Vite 4 upgrade. Does it work with unocss@0.47.5?

I couldn't find the source code of @dcloudio/vite-plugin-uni package. Do you know where is it?

@ModyQyW
Copy link
Author

ModyQyW commented Dec 15, 2022

@sibbng Thanks for your reply.

Could be related to Vite 4 upgrade.

I am using vite 3.2.5. Maybe you mean related to unocss upgrade for vite 4?

Does it work with unocss@0.47.5?

No. Doesn't work with unocss v0.47.0, v0.47.5 and v0.47.6. But works with unocss v0.46.5.

I couldn't find the source code of @dcloudio/vite-plugin-uni package. Do you know where is it?

I don't know where it is, either. Sorry about that.

https://github.com/dcloudio/uni-app/tree/next/packages/vite-plugin-uni

@ModyQyW
Copy link
Author

ModyQyW commented Dec 15, 2022

I just created a repo following the steps. You can try on it.

https://github.com/ModyQyW/playground

@sibbng
Copy link
Member

sibbng commented Dec 15, 2022

I looked at it but, couldn't find the source problem. Probably it's caused by #1926. But I don't think it's something we have to fix.

I believe this could be fixed on uni-app side by just changing the priority of a plugin. If you can show them #1926, they may know where the fix might be.

@ModyQyW
Copy link
Author

ModyQyW commented Dec 15, 2022

Thanks for your reply!

I have linked the issue. Can you please keep this issue open until the problem is solved? Thanks!

@yckbilly1929
Copy link

yckbilly1929 commented Dec 31, 2022

0.46.5 to 0.47.0 also breaks my build (a react SPA project). Below is the diff before and after, running unocss cli:

Screenshot 2022-12-31 at 20 28 25

and the only places with the word container:

Screenshot 2022-12-31 at 20 29 31

and my unocss.config.ts file:

Screenshot 2022-12-31 at 20 34 41

@ModyQyW
Copy link
Author

ModyQyW commented Dec 31, 2022

@yckbilly1929 You should open another issue for this. This issue focuses on uni-app and is solved. I am closing it.

@ModyQyW ModyQyW closed this as completed Dec 31, 2022
@yckbilly1929
Copy link

@yckbilly1929 You should open another issue for this. This issue focuses on uni-app and is solved. I am closing it.

no problem

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

3 participants