-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
238 lines (227 loc) · 9.28 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
const path = require('path');
var webpack = require('webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ConcatPlugin = require('webpack-concat-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
function injectHashesInLinks (content, path) {
var template = content.toString('utf8');
var now = Date.now();
var cssInjected = "";
var explodedTemplate = template.split('.css');
for (var i = 0; i < explodedTemplate.length; i++) {
cssInjected += explodedTemplate[i];
// If this is the last chunk, then we are at the end of file and should not append
if (explodedTemplate.length - i > 1) {
cssInjected += ".css?v=" + now;
}
}
var explodedTemplate = cssInjected.split('.js');
var jsAndCssInjected = "";
for (var i = 0; i < explodedTemplate.length; i++) {
jsAndCssInjected += explodedTemplate[i];
// If this is the last chunk, then we are at the end of file and should not append
if (explodedTemplate.length - i > 1) {
jsAndCssInjected += ".js?v=" + now;
}
}
return jsAndCssInjected;
}
module.exports = {
entry: {
scheduleSummaryReportApp: './app/scheduleSummaryReport/scheduleSummaryReportApp.js',
registrarReconciliationReportApp: './app/registrarReconciliationReport/registrarReconciliationReportApp.js',
teachingCallResponseReportApp: './app/teachingCallResponseReport/teachingCallResponseReportApp.js',
supportCallResponseReportApp: './app/supportCallResponseReport/supportCallResponseReportApp.js',
assignmentApp: './app/assignment/assignmentApp.js',
adminApp: './app/admin/adminApp.js',
budgetApp: './app/budget/budgetApp.js',
courseApp: './app/course/courseApp.js',
instructionalSupportApp: './app/instructionalSupport/instructionalSupportApp.js',
summaryApp: './app/summary/summaryApp.js',
schedulingApp: './app/scheduling/schedulingApp.js',
supportCallApp: './app/supportCall/supportCallApp.js',
supportAssignmentApp: './app/supportAssignment/supportAssignmentApp.js',
sharedApp: './app/shared/sharedApp.js',
teachingCallApp: './app/teachingCall/teachingCallApp.js',
workgroupApp: './app/workgroup/workgroupApp.js',
workloadSummaryReportApp: './app/workloadSummaryReport/workloadSummaryReportApp.js',
reportsApp: './app/reports/reportsApp.js'
},
output: {
filename: 'js/[name].js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
modules: [
path.resolve(__dirname, "app"),
"node_modules"
],
alias: {
Workgroup: path.resolve(__dirname, 'app/workgroup/'),
TeachingCall: path.resolve(__dirname, 'app/teachingCall/')
}
},
module: {
rules: [
{
// JS LOADER
// Reference: https://github.com/babel/babel-loader
// Transpile .js files using babel-loader
// Compiles ES6 and ES7 into ES5 code
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
}
},
],
exclude: /node_modules/
},
{
test: /\.html$/,
loader: 'raw-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
plugins: [
new CleanWebpackPlugin(),
// Copy html to output path (dist)
new CopyWebpackPlugin({
patterns: [
{
from: 'app/**/*.html',
to: '',
flatten: true,
transform: function (content, path) { return injectHashesInLinks(content, path); }
}
]
}),
// Copy json status to output path (dist)
new CopyWebpackPlugin({
patterns: [
{ from: 'app/**/*.json', to: '', flatten: true }
]
}),
// Copy css to output /css inside output path (dist)
new CopyWebpackPlugin({
patterns: [
{ from: 'vendor/css/**/*.css', to: 'css', flatten: true },
{ from: 'node_modules/bootstrap/dist/css/**/*.css', to: 'css', flatten: true }
]
}),
// Concat lib CSS
new ConcatPlugin({
sourceMap: false,
fileName: 'css/lib.css',
filesToConcat: [
'./node_modules/bootstrap/dist/css/bootstrap.css',
'./node_modules/fullcalendar/dist/fullcalendar.css',
'./node_modules/ng-notify/dist/ng-notify.min.css',
'./node_modules/ui-select/dist/select.css',
'./node_modules/@selectize/selectize/dist/css/selectize.default.css',
'./node_modules/jquery-typeahead/dist/jquery.typeahead.min.css'
],
}),
// Concat shared CSS
new ConcatPlugin({
sourceMap: false,
fileName: 'css/shared.css',
filesToConcat: [
'./app/shared/**/*.css',
'./app/shared/directives/**/*.css'
],
}),
// Copy fonts to output /fonts inside output path (dist)
new CopyWebpackPlugin({
patterns: [
{ from: 'vendor/fonts/**/*', to: 'fonts', flatten: true },
{ from: 'node_modules/bootstrap/dist/fonts/**/*', to: 'fonts', flatten: true },
{ from: 'vendor/font/**/*', to: 'font', flatten: true }
]
}),
// Copy assets to output /fonts inside output path (dist)
new CopyWebpackPlugin({
patterns: [
{ from: 'app/assets/images/*', to: 'images', flatten: true },
{ from: 'app/assets/images/colorpicker/*', to: 'images/colorpicker', flatten: true }
]
}),
// Copy vendor JS
new CopyWebpackPlugin({
patterns: [
{ from: 'clientConfig.js', to: 'js', flatten: true },
{ from: 'node_modules/bootstrap/dist/js/*', to: 'js', flatten: true },
{ from: 'node_modules/fuse.js/dist/fuse.min.js', to: 'js', flatten: true },
{ from: 'node_modules/jquery-typeahead/dist/jquery.typeahead.min.js', to: 'js', flatten: true },
{ from: 'vendor/js/*', to: 'js', flatten: true },
]
}),
// Concat lib JS
new ConcatPlugin({
uglify: false,
sourceMap: false,
fileName: 'js/lib.js',
filesToConcat: [
'./node_modules/jquery/dist/jquery.js',
'./node_modules/jquery-typeahead/dist/jquery.typeahead.min.js',
'./node_modules/underscore/underscore-min.js',
'./node_modules/moment/min/moment.min.js',
'./app/shared/helpers/string_prototypes.js',
'./node_modules/fullcalendar/dist/fullcalendar.js',
'./node_modules/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js',
'./node_modules/@selectize/selectize/dist/js/selectize.js'
],
}),
// Production Snippets from various 3rd party services
new ConcatPlugin({
uglify: false,
sourceMap: false,
fileName: 'js/snippets.js',
filesToConcat: ['./vendor/js/googleAnalytics.js'],
}),
new ESLintPlugin()
],
devServer: {
client: {
overlay: false,
progress: true
},
static: {
directory: path.join(__dirname, "dist"),
},
port: 9000,
proxy: {
"/*": {
target: "http://localhost:9000",
bypass: function(req, res, proxyOptions) {
if ((req.url.indexOf("/reports") > -1 ) && (req.url != "/reports.html")) { return "/reports.html"; }
if ((req.url.indexOf("/summary") > -1 ) && (req.url != "/summary.html")) { return "/summary.html"; }
if ((req.url.indexOf("/admin") > -1 ) && (req.url != "/admin.html")) { return "/admin.html"; }
if ((req.url.indexOf("/budget") > -1 ) && (req.url != "/budget.html")) { return "/budget.html"; }
if ((req.url.indexOf("/workgroups") > -1 ) && (req.url != "/workgroup.html")) { return "/workgroup.html"; }
if ((req.url.indexOf("/courses") > -1 ) && (req.url != "/course.html")) { return "/course.html"; }
if ((req.url.indexOf("/assignments") > -1 ) && (req.url != "/assignment.html")) { return "/assignment.html"; }
if ((req.url.indexOf("/instructionalSupport") > -1 ) && (req.url != "/instructionalSupport.html")) { return "/instructionalSupport.html"; }
if ((req.url.indexOf("/teachingCalls") > -1 ) && (req.url != "/teachingCall.html")) { return "/teachingCall.html"; }
if ((req.url.indexOf("/supportCalls") > -1 ) && (req.url != "/supportCall.html")) { return "/supportCall.html"; }
if ((req.url.indexOf("/supportAssignments") > -1 ) && (req.url != "/supportAssignment.html")) { return "/supportAssignment.html"; }
if ((req.url.indexOf("/scheduling") > -1 ) && (req.url != "/scheduling.html")) { return "/scheduling.html"; }
if ((req.url.indexOf("/registrarReconciliationReport") > -1 ) && (req.url != "/registrarReconciliationReport.html")) { return "/registrarReconciliationReport.html"; }
if ((req.url.indexOf("/teachingCallResponseReport") > -1 ) && (req.url != "/teachingCallResponseReport.html")) { return "/teachingCallResponseReport.html"; }
if ((req.url.indexOf("/scheduleSummaryReport") > -1 ) && (req.url != "/scheduleSummaryReport.html")) { return "/scheduleSummaryReport.html"; }
if ((req.url.indexOf("/supportCallResponseReport") > -1 ) && (req.url != "/supportCallResponseReport.html")) { return "/supportCallResponseReport.html"; }
if ((req.url.indexOf("/workloadSummaryReport") > -1 ) && (req.url != "/workloadSummaryReport.html")) { return "/workloadSummaryReport.html"; }
return req.url;
}
}
}
}
};