This repository has been archived by the owner on Sep 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
webpack.config.js
60 lines (56 loc) · 1.66 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
'use strict';
var fs = require('fs')
, path = require('path')
, webpack = require('webpack')
, console = require('console')
, WrapperPlugin = require('wrapper-webpack-plugin')
, headerComment = fs.readFileSync('./headConditionalComment.js')
, footerComment = fs.readFileSync('./footConditionalComment.js')
, exec = require('child_process').execSync
, gitDesc
, banner = ''
, bannerAppend = false
, lines = fs.readFileSync('./flowplayer.dashjs.js', 'utf8').split('\n');
try {
gitDesc = exec('git describe').toString('utf8').trim();
} catch (ignore) {
console.warn('unable to determine git revision');
}
lines.forEach(function (line) {
if (line === '/*!') {
bannerAppend = true;
}
if (bannerAppend) {
bannerAppend = line.indexOf('$GIT_DESC$') < 0;
if (gitDesc) {
line = line.replace('$GIT_DESC$', gitDesc);
}
banner += line + (bannerAppend ? '\n' : '\n\n*/');
}
});
module.exports = {
entry: {'flowplayer.dashjs.min': ['./standalone.js']},
externals: {
flowplayer: 'flowplayer'
},
module: {
loaders: [
{ test: /dashjs/, loader: 'babel', query: { presets: ['es2015'] } }
]
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js'
},
plugins: [
new webpack.optimize.OccurrenceOrderPlugin(true),
new webpack.optimize.UglifyJsPlugin({
include: /\.min\.js$/,
mangle: true,
output: { comments: false }
}),
new webpack.NormalModuleReplacementPlugin(/^webworkify$/, 'webworkify-webpack'),
new WrapperPlugin({header: headerComment, footer: footerComment}),
new webpack.BannerPlugin(banner, {raw: true})
]
};