-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
149 lines (132 loc) · 4.21 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
/**
* Copyright 2012-2017 Red Hat, Inc.
*
* Thermostat is distributed under the GNU General Public License,
* version 2 or any later version (with a special exception described
* below, commonly known as the "Classpath Exception").
*
* A copy of GNU General Public License (GPL) is included in this
* distribution, in the file COPYING.
*
* Linking Thermostat code with other modules is making a combined work
* based on Thermostat. Thus, the terms and conditions of the GPL
* cover the whole combination.
*
* As a special exception, the copyright holders of Thermostat give you
* permission to link this code with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on Thermostat code. If you modify Thermostat, you may
* extend this exception to your version of the software, but you are
* not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
'use strict';
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');
var ENV = process.env.npm_lifecycle_event;
var isTest = ENV === 'test' || ENV === 'test-watch';
var isProd = process.env.NODE_ENV === 'production';
module.exports = function () {
var config = {};
config.entry = isTest ? void 0 : {
app: './src/app/app.module.js'
};
config.resolve = {
alias: {
'jquery': 'angular-patternfly/node_modules/patternfly/node_modules/jquery',
'angular': 'angular-patternfly/node_modules/angular',
'd3': 'angular-patternfly/node_modules/patternfly/node_modules/d3',
'c3': 'angular-patternfly/node_modules/patternfly/node_modules/c3',
'bootstrap': 'angular-patternfly/node_modules/patternfly/node_modules/bootstrap/dist/js/bootstrap.js',
'bootstrap-switch': 'angular-patternfly/node_modules/patternfly/node_modules/bootstrap-switch',
'assets': path.resolve(__dirname, 'src', 'assets'),
'images': 'assets/images',
'scss': 'assets/scss',
'shared': path.resolve(__dirname, 'src', 'app', 'shared'),
'templates': 'shared/templates'
}
};
config.output = isTest ? {} : {
path: __dirname + '/dist',
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js'
};
if (isTest) {
config.devtool = 'inline-source-map';
} else if (isProd) {
config.devtool = 'source-map';
} else {
config.devtool = 'eval-source-map';
}
config.module = {
rules: [{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}, {
test: /\.scss$/,
loader: ['style-loader', 'css-loader', 'sass-loader'],
exclude: /node_modules/
}, {
test: /\.css$/,
use: ['style-loader', 'css-loader']
}, {
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: 'file-loader'
}, {
test: /\.html$/,
loader: 'html-loader'
}, {
test: /^(?!.*\.spec\.js$).*\.js$/,
include: __dirname + '/src/app/',
loaders: ['istanbul-instrumenter-loader', 'babel-loader']
}]
};
config.plugins = [];
config.plugins.push(
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jquery': 'jquery',
'window.jQuery': 'jquery',
d3: 'd3',
c3: 'c3'
})
);
config.plugins.push(
new webpack.EnvironmentPlugin({
NODE_ENV: 'development',
DEBUG: false,
GATEWAY_URL: 'http://localhost:8888'
})
);
if (isProd) {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})
);
}
if (!isTest) {
config.plugins.push(
new HtmlWebpackPlugin({
template: './src/app/index.html',
favicon: './src/assets/images/favicon.png',
inject: 'body'
})
);
}
config.devServer = {
host: '0.0.0.0',
contentBase: './src/assets',
stats: 'minimal',
inline: true,
historyApiFallback: true
};
return config;
}();