forked from Peer5/videojs-contrib-hls.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
68 lines (58 loc) · 1.51 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const LIB_NAME = 'HlsjsVideojsPlugin';
const DIST_DIR = 'dist';
const ENTRY_PATH = 'src/hlsjs-videojs-plugin'
const MINIMIZE = true;
function makeConfig(options = {}) {
const libName = options.libName || LIB_NAME;
const entryPath = options.entryPath || ENTRY_PATH;
const config = {
mode: process.env.WEBPACK_MODE || 'development',
entry: __dirname + '/' + entryPath,
devtool: 'source-map',
output: {
path: __dirname + '/' + DIST_DIR,
publicPath: '/' + DIST_DIR + '/',
filename: libName + '.min.js',
library: libName,
libraryTarget: 'umd',
libraryExport: 'default'
},
resolve: {
extensions: [".ts", ".js"]
},
module: {
rules: [
{ test: /\.ts$/, loader: "ts-loader" },
{ test: /\.js$/, exclude: [/node_modules/], loader: "ts-loader" },
]
},
optimization: {
minimize: MINIMIZE
},
externals: {
'video\.js': {
commonjs: 'video.js',
commonjs2: 'video.js',
amd: 'video.js',
root: 'videojs'
}
}
};
if (options.useExternalHlsjs) {
config.externals['hls\.js'] = {
commonjs: 'hls.js',
commonjs2: 'hls.js',
amd: 'hls.js',
root: 'Hls'
}
}
return config;
}
const appConfig = makeConfig({libName: LIB_NAME + 'AppExample', entryPath: 'examples/app'});
appConfig.externals = {};
const multiConfigs = [
makeConfig(),
makeConfig({useExternalHlsjs: true, libName: LIB_NAME + 'External'}),
appConfig
];
module.exports = multiConfigs;