-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.helpers.js
50 lines (43 loc) · 1.69 KB
/
webpack.helpers.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
var path = require('path');
var zlib = require('zlib');
var validateWebpackConfig = function (config) {
return config;
}; //require('webpack-validator');
var pkg = require('./package.json');
// Helper functions
var now = new Date();
var updated = now.getUTCFullYear() + '.' +
(now.getUTCMonth() < 9 ? '0' + (now.getUTCMonth() + 1) : (now.getUTCMonth() + 1)) + '.' +
(now.getUTCDate() < 10 ? '0' + now.getUTCDate() : now.getUTCDate()) + ' ' +
(now.getUTCHours() < 10 ? '0' + now.getUTCHours() : now.getUTCHours()) + ':' +
(now.getUTCMinutes() < 10 ? '0' + now.getUTCMinutes() : now.getUTCMinutes()) + ' UTC';
exports.version = pkg.version;
exports.updated = updated;
exports.validateWebpackConfig = validateWebpackConfig;
exports.validate = validateWebpackConfig;
function gzipMaxLevel(buffer, callback) {
return zlib['gzip'](buffer, {level: 9}, callback)
}
exports.gzipMaxLevel = gzipMaxLevel;
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
exports.root = root;
function rootNode(args) {
args = Array.prototype.slice.call(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}
exports.rootNode = rootNode;
function prependExt(extensions, args) {
args = args || [];
if (!Array.isArray(args)) { args = [args] }
return extensions.reduce(function(memo, val) {
return memo.concat(val, args.map(function(prefix) {
return prefix + val
}));
}, ['']);
}
exports.prependExt = prependExt;
exports.prepend = prependExt;
exports.HtmlWebpackPluginParams = { template: 'app/index.html', inject: 'body', minify: { collapseWhitespace: true, minifyJS: true, removeComments: true, minifyCSS: true } };