1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-14 11:23:30 +02:00
video.js/docs/guides/webpack.md

52 lines
1.7 KiB
Markdown
Raw Normal View History

# Using Webpack with Video.js
Video.js, and the playback technologies such as videojs-contrib-hls all work in a Webpack based build environment. Here are several configuration changes specific to Webpack that will get you up and running.
## Video.js CSS:
2018-10-10 17:09:53 +02:00
To add the CSS that the player requires, simply add
`require('!style-loader!css-loader!video.js/dist/video-js.css')` to the file where the player is also included or initialized.
## Handling .eot files in Webpack
2018-10-10 17:09:53 +02:00
In addition to this, you may run into a problem where Webpack does not know how to load .eot files required for IE8 support by default. This can be solved by installing the file-loader and url-loader packages. Install them by running:
2018-10-10 17:09:53 +02:00
```sh
npm install --save-dev file-loader url-loader
```
2018-10-10 17:09:53 +02:00
With both packages installed, simply add the following to you webpack.config file in the 'loaders' section:
```js
{
loader: 'url-loader?limit=100000',
test: /\.(png|woff|woff2|eot|ttf|svg)$/
}
```
## Using Webpack with videojs-contrib-hls
2018-10-10 17:09:53 +02:00
Import the HLS library with a line such as:
2018-10-10 17:09:53 +02:00
```sh
import * as HLS from 'videojs-contrib-hls';
```
In order to use the tech, we must also introduce webworkers with the package 'webworkify-webpack-dropin', run:
2018-10-10 17:09:53 +02:00
```sh
npm install --save-dev webworkify-webpack-dropin
```
2018-10-10 17:09:53 +02:00
To utilize this in your page, simply create an alias in your webpack.config.js file with:
```js
resolve: {
alias: {
webworkify: 'webworkify-webpack-dropin'
}
}
```
Source maps that use the 'eval' tag are not compatible with webworkify, so this may need to be changed also. Source maps such as 'cheap-eval-module-source-map' should be changed to 'cheap-source-map' or anything else that fits your build without using 'eval' source maps.