This repository has been archived by the owner on Sep 27, 2022. It is now read-only.
forked from aullman/opentok-meet
-
Notifications
You must be signed in to change notification settings - Fork 42
/
webpack.config.js
77 lines (70 loc) · 1.95 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
69
70
71
72
73
74
75
76
77
const webpack = require('webpack');
const path = require('path');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();
let version;
let commitHash;
try {
version = JSON.stringify(gitRevisionPlugin.version());
commitHash = JSON.stringify(gitRevisionPlugin.commithash());
} catch (e) {
// In Heroku we're not running from a git repo and the commit hash is in the path
version = JSON.stringify('unknown');
commitHash = JSON.stringify(process.env.PWD);
}
const production = process.env.HEROKU || process.env.TRAVIS;
const config = {
entry: {
login: './src/js/login/app.js',
room: './src/js/app.js',
screen: './src/js/screen/app.js',
whiteboard: './src/js/whiteboard/app.js',
},
output: {
path: './public/js/',
filename: '[name].bundle.min.js',
chunkFilename: '[id].chunk.min.js',
},
devtool: 'source-map',
module: {
loaders: [
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.html$/, loader: 'raw' },
{
test: /\.(?:jpeg|jpg|png|gif|bmp)$/i,
loader: 'file-loader?name=/images/[name].[ext]',
},
],
},
resolveLoader: {
root: path.join(__dirname, 'node_modules'),
},
plugins: [
new webpack.DefinePlugin({
VERSION: version,
COMMITHASH: commitHash,
}),
new webpack.optimize.CommonsChunkPlugin({
filename: 'commons.min.js',
name: 'commons',
}),
],
};
if (production) {
// Add in dedupe, uglify and babel for production
config.plugins = config.plugins.concat([
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin(),
]);
config.module.loaders = config.module.loaders.concat([
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules(?!\/(opentok-textchat|opentok-camera-filters|filterous))/,
query: {
presets: ['babel-preset-env'].map(require.resolve),
},
},
]);
}
module.exports = config;