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

Getting Plugins to work with the kit #90

Open
Progression opened this issue Aug 18, 2022 · 5 comments
Open

Getting Plugins to work with the kit #90

Progression opened this issue Aug 18, 2022 · 5 comments

Comments

@Progression
Copy link

I need to use some plugins but am having issues getting them to work with the videojs-mux-kit version.

I have seen the note at the end of the readme regarding video.js/core situation. I've tried both solutions:

  • using the VHS build - plugins still don't work and Mux video playback is problematic when loading video source using javascript
  • using the alias plugin for my vite.config.js but that seems to have no effect (no vite compile errors but I can't work out how to test if the alias are actually loading the core version)
import alias from '@rollup/plugin-alias';

export default defineConfig({
    plugins: [
        alias({
             entries: [
                 { find: 'video.js', replacement: resolve.resolve('video.js/core') },
             ]
        }),
    ],
});

I guess what I'm really interested in knowing is has anyone got plugins to work with the latest version of videojs-mux-kit?

@gkatsev
Copy link
Contributor

gkatsev commented Aug 19, 2022

Hey, thanks for the issue. There's definitely some finickiness around plugins. We'll take a look next week.

@gkatsev
Copy link
Contributor

gkatsev commented Aug 25, 2022

Looking at the vite docs, I can see that they actually ship with it built-in: https://vitejs.dev/config/shared-options.html#resolve-alias

However, I fonud out why this isn't working. We're bundling video.js into the built file, so, there is always two versions of Video.js around. I'll take a look at how to separate it out so that aliasing will start working again.

@gkatsev
Copy link
Contributor

gkatsev commented Aug 25, 2022

Figured out a workaround. If you alias video.js to point at videojs-mux-kit itself, it works:

import { defineConfig } from 'vite';

export default defineConfig({
  resolve: {
    alias: {
      'video.js': '@mux/videojs-kit',
    },
  },
});

I have a live example over here: https://stackblitz.com/edit/vitejs-vite-v8dbe2?file=main.js,package.json,vite.config.js&terminal=dev

@Progression hopefully, that unblocks you. I'll continue looking into how to make the build better, though. I'm not sure that there's a way to avoid aliasing altogether, unfortunately.

@Progression
Copy link
Author

Gary, that is great, thanks so much for looking into this. I'm unable to try this out myself tonight but will see if I can jump over to this tomorrow and get it working. Will let you know.

@ShawnAukstak
Copy link

ShawnAukstak commented Nov 16, 2022

@gkatsev's solution also worked for me running webpacker in Rails with the videojs-record plugin.

I changed the alias from 'video.js': 'video.js/core' to 'video.js': '@mux/videojs-kit' and it finds the plugin and works.

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