This repository was archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathwebpack.js
More file actions
82 lines (77 loc) · 2.2 KB
/
Copy pathwebpack.js
File metadata and controls
82 lines (77 loc) · 2.2 KB
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
78
79
80
81
82
const path = require('path');
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = function (grunt) {
const isProduction = grunt.cli.tasks[0] === 'release';
const plugins = [
new webpack.SourceMapDevToolPlugin({
filename: '[file].map',
exclude: [/^(?!(binary)).*$/],
}),
new webpack.optimize.UglifyJsPlugin({
include : /^binary.*/,
minimize : true,
sourceMap: true,
compress : {
warnings: false,
},
}),
];
if (!isProduction) {
plugins.push(
function() {
this.plugin('watch-run', function(watching, callback) {
console.log('');
grunt.log.ok('Compile started at ' + new Date());
callback();
});
}
);
}
const common_options = {
node: {
fs : 'empty',
net : 'empty',
tls : 'empty',
crypto: 'empty',
Buffer: false,
},
cache: true,
externals: {
'jquery' : {
commonjs: "jquery",
commonjs2: "jquery",
amd: "jquery",
root: "jQuery"
},
},
entry: {
binary : './src/js/binary',
'binary.more': './src/js/binary.more',
},
output: {
path : path.resolve(__dirname, '../' + global.dist),
filename: '[name].js',
libraryTarget: 'umd',
},
module: {
loaders: [
{
test : /\.js$/,
exclude: /node_modules|oauth/,
loader : 'babel-loader',
query : {
presets: ['es2015'],
compact: false,
},
},
],
},
plugins: plugins,
};
const watch_options = Object.assign({ watch: true }, common_options);
return {
build: common_options,
watch: watch_options,
}
};