-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Style not loaded in React+Webpack #7158
Comments
Do you have a live example of this? I'd expect it to work. Make sure that the player div ends up with a |
Hi @gkatsev!
Nope, but the whole code is in the OP. What is missing is this small snippet in
Checked that, it's alright. I'm pretty sure the issue concerns the loaders, since I created a sample videojs React project (without Webpack), and the style is loaded correctly with I also checked the versions of the loaders:
Unfortunately, even after updating the ones in the project w/ Webpack, it doesn't work. May we arrange a meeting on Jitsi or whatever? I would like to show my code to you in person, and I will make sure to report here the possibly discussed passages during the meeting. |
Hi @gkatsev. I forgot to mention that my React.js project involves WebComponents, so this stuff
is actually in the shadowDOM. I've read here that video.js ignores videos outside the DOM: in fact, I get this warning
After some searching for "video.js webcomponents support" and similar, I found this library by @mister-ben and @eXon, but it seems a bit outdated and relying on bower and polymer (which I don't have in my project, and I use npm). Since I can't open an issue on their repo, could you (@mister-ben and @eXon) give me any suggestions, please? |
My repo was a fork of eXon's since deleted repo. I've not looked much into WebComponents since, sorry. |
No problem. Thank you anyway! I'll be glad to hear from @eXon :) |
The way we check to see whether the video element passed to Video.js, unfortunately, doesn't currently take shadow DOM into account. All our CSS also assumes light DOM. Supposedly, there's a way to include css inside the shadow DOM https://stackoverflow.com/a/23286832, which should potentially resolve your issue. |
That code is looking for the HEAD element (https://github.com/videojs/video.js/blob/main/src/js/player.js#L750-L756) which probably doesn't exist in the shadow dom. |
You're right: HEAD is the head of the lightDOM (i.e.
I added this two lines in
and now it works like a charm! Thank you so much for your help :-) |
Hello everyone. My goal is to add a videojs player in an already existing React+Webpack project.
This is an excerpt from the existing
webpack.config.js
:and I'm implementing videojs in
VideojsManagement.js
:When I build, my code does not seem to work:
I read how to use Webpack with videojs, and had a look at this comment in another issue. So, in
webpack.config.js
I replacedwith
It does build, but the stylesheet is not loaded, and the video player seems like broken:
Although I'm not familiar with Webpack, I've also made various changes in the code of
webpack.config.js
, like:video.js
folderstyle-loader
beforeto-string-loader
style-loader
andcss-loader
I tried various combinations of the proposed changes, but still no luck. Any suggestions would be appreciated.
Thanks in advance!
The text was updated successfully, but these errors were encountered: