videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
381 stars 257 forks source link

Import with webpack and laravel mix #299

Closed Nks closed 6 years ago

Nks commented 6 years ago

Hey to all. I'm using laravel mix 1.6.0 to concatenate all scripts. So, I've no problem with video.js library, but with videojs-contrib-ads it won't work. For example I importing like this: window.videojs = require('video.js'); import 'videojs-contrib-ads/dist/videojs.ads';

and in this case I got the error: embed.js?id=3c7859f920457c2f6805:51130 Uncaught TypeError: Cannot read property 'getTech' of undefined at Object.<anonymous> (embed.js?id=3c7859f920457c2f6805:51130) at Object.10../cancelContentPlay.js (embed.js?id=3c7859f920457c2f6805:51897) at s (embed.js?id=3c7859f920457c2f6805:50226) at e (embed.js?id=3c7859f920457c2f6805:50226) at embed.js?id=3c7859f920457c2f6805:50226 at ./node_modules/videojs-contrib-ads/dist/videojs.ads.js.i (embed.js?id=3c7859f920457c2f6805:50226) at Object.<anonymous> (embed.js?id=3c7859f920457c2f6805:50226) at Object../node_modules/videojs-contrib-ads/dist/videojs.ads.js (embed.js?id=3c7859f920457c2f6805:51900) at __webpack_require__ (embed.js?id=3c7859f920457c2f6805:20) at Object../resources/assets/js/embed.js (embed.js?id=3c7859f920457c2f6805:54087)

and video.js broking in this case too.

Is the plugin support ES6 fully or not? Or maybe I'm importing it in wrong way? Thanks.

Nks commented 6 years ago

yes, I imported these items with wrong way. Correct way is:

import videojs from 'video.js';
import 'videojs-contrib-ads';
import 'videojs-ima';

And then send videojs variable to the class which should use videojs and it will work fine.