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

import tailwind in popup html #13

Open
Benbinbin opened this issue Sep 6, 2021 · 9 comments
Open

import tailwind in popup html #13

Benbinbin opened this issue Sep 6, 2021 · 9 comments

Comments

@Benbinbin
Copy link

Thanks to create this plugin.
I try to follow the tutorial Create a Chrome Extension with Vite + Vue by
Alvaro Dev Labs to build a Chrome extension with Vite+Vue+Tailwind.

But I have a problem, it seems that if I build a pupup page for Action (not the popup for content-script as the video tutorial), the tailwindcss don't work correctly, the css file can generate when build, but it can't link to the HTML correctly, maybe the difference between my situation and the video tutorial is the entry point, the content-script entry point is js file, and the popup page entry point is a html file in manifest.json.

the reproduce repo: https://github.com/Benbinbin/extension-vite-vue-demo

@boka18
Copy link

boka18 commented Sep 22, 2021

Hey @Benbinbin, I have the exact same issue. Were you able to resolve it somehow?

@Benbinbin
Copy link
Author

@boka18 sorry, I can't find a solution by using this plugin. Now I change the plugin to this one and it works fine. The developer also provides a template to build extension with vite+vue+manifestV3.

@boka18
Copy link

boka18 commented Sep 23, 2021

got it @Benbinbin! thank you!

I was also able to create starter template for react (with this plugin)

You can check out the boilerplate here:
https://github.com/boka18/vite-react-chrome-extension-example

It's forked from here:
https://github.com/alvarosaburido/vite-vue-chrome-extension-example
In the above repo, it was built for vue. I managed to port that to react

@tyanbiao
Copy link

tyanbiao commented Dec 6, 2021

same issue

@reducm
Copy link

reducm commented Dec 16, 2021

found the docs said The entries of options and popup pages are HTML files, their outputs are same as nomarl page. link

its not a good solution that can import css as string, an then add to the document

such as I used the element-plus, in your main.ts

import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import cssString from 'element-plus/dist/index.css'


const style = document.createElement('style');
document.head.append(style);
style.textContent = cssString;

createApp(App).use(ElementPlus).mount('#app')

@ciricc
Copy link

ciricc commented Dec 16, 2021

I have the same problem with windicss import 'virtual:windi.css' in Svelte application popup. Css generates, but not link into HTML correctly

@ciricc
Copy link

ciricc commented Dec 16, 2021

@reducm Thank you, that's worked for me

@evanb2
Copy link

evanb2 commented Jan 11, 2022

@reducm I'm not using ElementPlus, but after adding the other parts of your solution I'm still not getting Tailwind imported. When I inspect the popup DOM I don't see the <style> element. Is ElementPlus adding some functionality for this to work for you?

@reducm
Copy link

reducm commented Jan 13, 2022

@reducm I'm not using ElementPlus, but after adding the other parts of your solution I'm still not getting Tailwind imported. When I inspect the popup DOM I don't see the <style> element. Is ElementPlus adding some functionality for this to work for you?

to my knowledge, the elementPlus css is just some css string, and I found it did add en style tag to the document head

image

i think maybe some js code overwrite it, you code just use this code(remove other import) to see is there a style tag in head

import cssString from 'someCss'


const style = document.createElement('style');
document.head.append(style);
style.textContent = cssString;

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

6 participants