-
Notifications
You must be signed in to change notification settings - Fork 22
/
webpack.config.js
158 lines (149 loc) · 3.53 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
const webpack = require('webpack');
var UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
var CircularDependencyPlugin = require("circular-dependency-plugin");
var ProvidePlugin = webpack.ProvidePlugin;
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var NODE_ENV = process.env.NODE_ENV || 'development';
var EXT_LIB = process.env.EXT_LIB || 'default';
var isDev = NODE_ENV === 'development';
var isTest = NODE_ENV === 'test';
var isProduction = NODE_ENV === 'production';
var isExternal = (EXT_LIB === 'true') || (EXT_LIB === '1');
var libraryName = "mutationMapper";
var outputLibFile = libraryName + ".js";
var outputStyleFile = libraryName + ".css";
var plugins = [];
// devServer config
var devHost = process.env.HOST || 'localhost';
var devPort = process.env.PORT || 3080;
if (isProduction) {
plugins.push(new UglifyJsPlugin({ minimize: true }));
outputLibFile = libraryName + ".min.js";
outputStyleFile = libraryName + ".min.css";
}
plugins = [
new CircularDependencyPlugin(),
new ExtractTextPlugin(outputStyleFile),
new ProvidePlugin({
$: "jquery",
jQuery: "jquery"
//"window.jQuery": "jquery"
})
].concat(plugins);
var externals = null;
var imageLoader = {
test: /\.(jpe?g|png|gif|ico)$/i,
loader: "file?name=images/[name].[ext]"
};
var fontLoader = {
test: /\.(ttf|eot|svg|woff2?)(\?v=[a-z0-9=\.]+)?$/i,
loader: "file?name=images/[name].[ext]"
};
// configure externals
if (isExternal)
{
externals = [
"d3",
"jquery-expander",
"jquery-flesler-scrollto",
{
"jquery": {
root: "jQuery",
amd: "jquery",
commonjs: "jquery",
commonjs2: "jquery"
},
"underscore": {
root: "_",
amd: "underscore",
commonjs: "underscore",
commonjs2: "underscore"
},
"backbone": {
root: "Backbone",
amd: "backbone",
commonjs: "backbone",
commonjs2: "backbone"
},
"filesaver.js-npm": {
root: "window",
amd: "filesaver.js-npm",
commonjs: "filesaver.js-npm",
commonjs2: "filesaver.js-npm"
},
"3dmol/release/3Dmol-nojquery": {
root: "$3Dmol",
amd: "3dmol/release/3Dmol-nojquery",
commonjs: "3dmol/release/3Dmol-nojquery",
commonjs2: "3dmol/release/3Dmol-nojquery"
}
},
/qtip2/,
/jquery-tipTip/,
/jquery-ui/,
/datatables\.net/,
/datatables\-/
// TODO legacy libs (ones with no npm entry)
///ui\.tabs\.paging/,
///fnSetFilteteringDelay/
];
imageLoader.exclude = /node_modules/;
fontLoader.exclude = /node_modules/;
}
var config =
{
entry: __dirname + "/src/js/api.js",
output: {
path: __dirname + "/build",
filename: outputLibFile,
library: libraryName,
libraryTarget: "umd"
},
module: {
loaders: [
imageLoader,
fontLoader,
{test: /\.css$/, loader: ExtractTextPlugin.extract(
'style',
'css?')
},
{
test: /.*template.*\.html$/,
loader: "underscore-template-loader",
query: {
interpolate: "\\{\\{(.+?)\\}\\}",
root: __dirname,
parseDynamicRoutes: true
}
},
// disable AMD for datatables, we are using CommonJS
{
test: require.resolve("datatables.net"),
loader: "imports?define=>false"
}
]
},
externals: externals,
resolve: {
alias: {
'jquery-ui': 'jquery-ui/ui/widgets',
'jquery-ui-css': 'jquery-ui/../../themes/base',
'datatables': __dirname + '/src/js/helper/datatables'
}
},
plugins: plugins,
devServer: {
historyApiFallback: false,
hot: false,
noInfo: false,
quiet: false,
lazy: false,
publicPath: '/',
contentBase: 'build',
https: false,
hostname: devHost,
port: devPort,
stats:'errors-only'
}
};
module.exports = config;