-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (75 loc) · 2.04 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
78
79
80
81
82
83
84
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
// List all files in a directory in Node.js recursively in a synchronous fashion
// List all files in a directory in Node.js recursively in a synchronous fashion
var walkSync = function (dir, filelist) {
if (dir[dir.length - 1] != '/')
dir = dir.concat('/')
var fs = fs || require('fs'),
files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach(function (file) {
if (fs.statSync(dir + file).isDirectory()) {
filelist = walkSync(dir + file + '/', filelist);
}
else {
// build regex search
var re = new RegExp(/\kjsmodule.(json)/g);
if (re.test(file)) {
console.log(file);
filelist.push(dir + file);
}
}
});
// console.log(filelist);
return filelist;
};
var getAppEntries = function (dir) {
var files = walkSync(dir);
//var parsedJSON = require(x);
var mergeJSON = require("merge-json");
var result = {};
files.forEach(function (file) {
var json = require(file);
//console.log(json)
result = mergeJSON.merge(result, json);
});
console.log(result);
return result;
}
module.exports = {
context: __dirname,
devtool: debug ? "sourcemap" : false,//or sourcemap
entry: getAppEntries(__dirname),
// {
// octagrid: './octagrid/grid.ts',
// formbuilder: './octagrid/formbuilder.ts',
// trainingapp: './myapp/trainingapp.ts',
// },
output: {
path: path.join(__dirname, 'dist'),
filename: '[name]/[name].bundle.js'
},
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
include: path.resolve(__dirname, 'octagrid'),
exclude: /node_modules/,
},
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
}
,
plugins: debug ? [] : [
//remove duplicate codes
// new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
//uglify
// new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
],
};