forked from ucfopen/Materia-Server-Client-Assets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
185 lines (183 loc) · 6.41 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
const glob = require('glob');
const path = require('path');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const CleanWebpackPlugin = require('clean-webpack-plugin')
const jsPath = path.join(__dirname, 'src', 'js')
const cssPath = path.join(__dirname, 'src', 'css')
const outPath = path.join(__dirname, 'dist')
// Create object with:
// Key = output name, Value = sass file
// for every scss file in the directory
// EX: { 'css/<filename>.css' : './src/css/filename.scss', ...}
let cssEntries = {}
glob.sync(path.join(cssPath, '*.scss')).forEach(function(file){
cssEntries['css/'+path.basename(file, '.scss')+'.css'] = file
})
module.exports = {
stats: { children: false, modules: false }, // reduce noising webpack print output
entry: {...cssEntries, ...{
// materia.js present on every page on the server except inside widget iframe & error pages
// contains common libs used by other scripts
// contains everything needed by all pages that don't require a login
'js/materia.js':[
// polyfills
"core-js/es6/array",
"core-js/fn/array/includes",
"core-js/es6/symbol",
"core-js/es6/promise",
"core-js/fn/object/assign",
"core-js/fn/string/includes",
"core-js/web/dom-collections",
"whatwg-fetch",
// end polyfills
jsPath+'/materia-namespace.js',
jsPath+'/materia/materia.coms.json.js',
jsPath+'/materia/materia.flashcheck.js',
jsPath+'/materia/materia.image.js',
jsPath+'/materia/materia.page.default.js',
jsPath+'/materia/materia.set.throbber.js',
jsPath+'/materia/materia.store.slideshow.js',
jsPath+'/materia/materia.user.js',
jsPath+'/materia/materia.util.js',
jsPath+'/materia/materia.validate.textfield.js',
jsPath+'/materia-constants.js',
jsPath+'/controllers/ctrl-alert.js',
jsPath+'/controllers/ctrl-current-user.js',
jsPath+'/controllers/ctrl-help.js',
jsPath+'/controllers/ctrl-login.js',
jsPath+'/controllers/ctrl-notification.js',
jsPath+'/controllers/ctrl-spotlight.js',
jsPath+'/controllers/ctrl-widget-catalog.js',
jsPath+'/controllers/ctrl-widget-details.js',
jsPath+'/services/srv-datetime.js',
jsPath+'/services/srv-please.js',
jsPath+'/services/srv-selectedwidget.js',
jsPath+'/services/srv-user.js',
jsPath+'/services/srv-widget.js',
'ngmodal/dist/ng-modal.min.js'
],
// student.js - all the stuff needed to be a student. play, view scores, profile
'js/student.js': [
jsPath+'/controllers/ctrl-player.js',
jsPath+'/controllers/ctrl-profile.js',
jsPath+'/controllers/ctrl-scores.js',
jsPath+'/controllers/ctrl-settings.js',
jsPath+'/directives/dir-beardable.js',
jsPath+'/directives/dir-datatable.js',
jsPath+'/directives/dir-date-validation.js',
jsPath+'/directives/dir-fullscreen.js',
jsPath+'/directives/dir-ngenter.js',
jsPath+'/directives/dir-scoregraph.js',
jsPath+'/directives/dir-scoretable.js',
jsPath+'/materia/materia.scores.scoregraphics.js',
jsPath+'/services/srv-api.js',
jsPath+'/services/srv-scores.js',
],
// author.js - all scripts for creating content: my widgets, widget authoring, lti picker
'js/author.js': [
jsPath+'/controllers/ctrl-collaboration.js',
jsPath+'/controllers/ctrl-create.js',
jsPath+'/controllers/ctrl-export-scores.js',
jsPath+'/controllers/ctrl-lti.js',
jsPath+'/controllers/ctrl-media-import.js',
jsPath+'/controllers/ctrl-my-widgets.js',
jsPath+'/controllers/ctrl-question-import.js',
jsPath+'/controllers/ctrl-selectedwidget.js',
jsPath+'/controllers/ctrl-widget-settings.js',
jsPath+'/directives/dir-beardable.js',
jsPath+'/directives/dir-datatable.js',
jsPath+'/directives/dir-date-validation.js',
jsPath+'/directives/dir-filedropper.js',
jsPath+'/directives/dir-fileonchange.js',
jsPath+'/directives/dir-ngenter.js',
jsPath+'/directives/dir-scoredata.js',
jsPath+'/directives/dir-scoregraph.js',
jsPath+'/directives/dir-scoretable.js',
jsPath+'/filters/filter-escape.js',
jsPath+'/filters/filter-highlight.js',
jsPath+'/filters/filter-multiword.js',
jsPath+'/materia/materia.mywidgets.statistics.js',
jsPath+'/services/srv-api.js',
jsPath+'/services/srv-beard.js',
jsPath+'/services/srv-scores.js',
],
// only used on admin interface pages
'js/admin.js':[
jsPath+'/controllers/ctrl-admin-user.js',
jsPath+'/controllers/ctrl-admin-widget.js',
jsPath+'/services/srv-admin.js',
],
'js/materia.creatorcore.js': [
jsPath+'/materia-namespace.js',
jsPath+'/materia/materia.creatorcore.js',
],
'js/materia.enginecore.js': [
jsPath+'/materia-namespace.js',
jsPath+'/materia/materia.enginecore.js',
jsPath+'/materia/materia.score.js',
jsPath+'/materia/materia.storage.manager.js',
jsPath+'/materia/materia.storage.table.js',
],
'js/materia.scorecore.js': [
jsPath+'/materia-namespace.js',
jsPath+'/materia/materia.scorecore.js',
]
}},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
use: ['webpack-strip-block']
},
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: [
">0.25%",
"not ie 10",
"not op_mini all"
]
},
}
]
],
plugins: [
require('babel-plugin-angularjs-annotate'),]
}
}
},
// SASS files
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
use: [
'css-loader?url=false', // disable the css-loaders' function of locating image urls
'sass-loader'
]
})
}
]
},
output: {
path: outPath,
filename: '[name]'
},
plugins: [
new CleanWebpackPlugin(), // clear the dist folder before build
new ExtractTextPlugin('[name]'), // pull the css out of webpack
],
resolve: {
alias: {
// allow the code to require from node_modules
'node_modules': path.join(__dirname, 'node_modules')
}
}
};