forked from clappr/clappr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
62 lines (47 loc) · 1.82 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
/* eslint-disable no-console */
const path = require('path')
const webpack = require('webpack')
const webpackConfig = require('./webpack-base-config')
const voidModulePath = path.resolve('./src/base/void')
const minimize = !!process.env.MINIMIZE
const forceInlineDebug = !!process.env.CLAPPR_INLINE_DEBUG
const plainHtml5Only = !!process.env.CLAPPR_PLAIN_HTML5_ONLY
let distroFlavor
webpackConfig.entry = path.resolve(__dirname, 'src/main.js')
if (minimize) {
console.log('NOTE: Enabled minifying bundle (uglify)')
webpackConfig.plugins.push(new webpack.LoaderOptionsPlugin({ minimize, debug: !minimize }))
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
mangle: true,
sourceMap: true,
comments: false,
output: { comments: false }
}))
}
if (plainHtml5Only) {
console.log('NOTE: Building only with plain HTML5 playback plugins, but will result in smaller build size')
distroFlavor = 'plainhtml5'
webpackConfig.plugins.push(
new webpack.NormalModuleReplacementPlugin(/playbacks\/flash/, voidModulePath),
new webpack.NormalModuleReplacementPlugin(/playbacks\/base_flash_playback/, voidModulePath),
new webpack.NormalModuleReplacementPlugin(/playbacks\/flashls/, voidModulePath),
new webpack.NormalModuleReplacementPlugin(/playbacks\/hls/, voidModulePath)
)
}
if (forceInlineDebug) {
console.log('NOTE: Enabling inline source-maps - this may not be suitable for production usage')
webpackConfig.devtool = 'inline-source-map'
}
console.log('\n')
const filename =
`clappr${ distroFlavor ? '.' + distroFlavor : '' }${ forceInlineDebug ? '.debug' : '' }${ minimize ? '.min' : '' }.js`
webpackConfig.output = {
path: path.resolve(__dirname, 'dist'),
filename,
library: 'Clappr',
libraryTarget: 'umd'
}
module.exports = webpackConfig