forked from wordpress-clients/hybrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.prod.js
41 lines (38 loc) · 1.46 KB
/
webpack.config.prod.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
var path = require('path'),
fs = require('fs'),
webpack = require("webpack"),
libPath = path.join(__dirname, 'lib'),
distPath = path.join(__dirname, 'dist'),
pkg = require('./package.json'),
cordovaLib = require('cordova').cordova_lib,
extend = require('util')._extend,
deepExtend = require('deep-extend'),
CSON = require('cson'),
projectConfig = deepExtend(CSON.requireFile('./config/config.default.cson'), CSON.requireFile('./config/config.cson')),
webpackConfig = require('./webpack.config.js'),
HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = extend(webpackConfig, {
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
pkg: pkg,
serviceWorkerEnabled: projectConfig.serviceWorker.enabled,
appVersion: getAppVersion(),
template: path.join(libPath, 'index.html')
}),
new webpack.ContextReplacementPlugin(/moment\/locale$/, getRegexAutorizedLanguages()),
new webpack.DefinePlugin({
IS_PROD: true
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin()
]
});
function getRegexAutorizedLanguages() {
return new RegExp(projectConfig.translation.displayed.join('|'));
}
function getAppVersion() {
var config = new cordovaLib.configparser(__dirname + '/config.xml');
return config.version();
}