-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.mix.js
363 lines (326 loc) · 17.6 KB
/
webpack.mix.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
const mix = require('laravel-mix');
const {GitRevisionPlugin} = require('git-revision-webpack-plugin');
const WebpackShellPluginNext = require('webpack-shell-plugin-next');
// npm run dev --env.version <version>
let version;
let gitRevisionPluginList = [];
if (typeof process.env.npm_config_output_version !== 'undefined' &&
process.env.hasOwnProperty('npm_config_output_version') &&
typeof process.env.npm_config_output_version !== 'undefined') {
version = process.env.npm_config_output_version;
} else {
let gitRevisionPlugin = new GitRevisionPlugin({
versionCommand: 'rev-list HEAD -1'
});
gitRevisionPluginList.push(gitRevisionPlugin);
version = gitRevisionPlugin.version();
// Write the version that's going to be used to file
const fs = require('node:fs');
fs.writeFile('version', version, err => {
if (err) {
console.error(err);
} else {
// file written successfully
}
});
}
mix.options({
// This dramatically speeds up the build process - adding new .scss for the redesign greatly increased build times without this
processCssUrls: false
}).webpackConfig({
output: {
publicPath: '/',
},
watchOptions: {
ignored: ['node_modules', 'vendor', 'storage'],
poll: 2000 // Check for changes every two seconds
},
// Handlebars has a bug which requires this: https://github.com/wycats/handlebars.js/issues/1174
resolve: {
alias: {
handlebars: 'handlebars/dist/handlebars.min.js'
}
},
// Translations
module: {
rules: [{
// Matches all PHP or JSON files in `resources/lang` directory.
test: /lang.+\.(php|json)$/,
loader: 'laravel-localization-loader',
}]
},
plugins: [
// Compile handlebars
new WebpackShellPluginNext({
onBuildStart: {
scripts: [
// Compile handlebars
'handlebars ' + (mix.inProduction() ? '-m ' : '') +
'resources/assets/js/handlebars/ -f resources/assets/js/handlebars.js'
],
blocking: true,
parallel: false
},
onBuildEnd: []
})
// Use git version to output our files
].concat(gitRevisionPluginList)
});
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
// npm run dev --env.full true
// false if not defined, true if defined
let full = false;
if (typeof process.env.npm_config_full !== 'undefined' &&
process.env.hasOwnProperty('npm_config_full') &&
typeof process.env.npm_config_full !== 'undefined') {
full = process.env.npm_config_full;
}
// npm run dev --env.images false
let images = false;
if (typeof process.env.npm_config_images !== 'undefined' &&
process.env.hasOwnProperty('npm_config_images') &&
typeof process.env.npm_config_images !== 'undefined') {
images = process.env.npm_config_images;
}
mix.copy('node_modules/@fortawesome/fontawesome-free/webfonts', 'public/webfonts');
mix.copy('resources/assets/webfonts', 'public/webfonts');
mix.copy('resources/assets/vendor/', 'public/vendor');
let precompile = [
// Translations
'resources/assets/js/messages.js'
];
mix.js(precompile, 'resources/assets/js/precompile.js');
let scripts = [
// Include the precompiled scripts
'public/resources/assets/js/precompile.js',
// Pre-compiled handlebars
'resources/assets/js/handlebars.js',
// Home page only
'resources/assets/js/custom/home.js',
// Doesn't depend on anything
'resources/assets/js/custom/colorutil.js',
'resources/assets/js/custom/util.js',
'resources/assets/js/custom/constants.js',
// Include in proper order
'resources/assets/js/custom/signalable.js',
// Map plugins
'resources/assets/js/custom/mapplugins/mapplugin.js',
'resources/assets/js/custom/mapplugins/patherplugin.js',
'resources/assets/js/custom/mapplugins/heatplugin.js',
// Map object groups
'resources/assets/js/custom/mapobjectgroups/mapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/polygonmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/polylinemapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/brushlinemapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/dungeonfloorswitchmarkermapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/enemymapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/enemypackmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/enemypatrolmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/killzonemapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/killzonepathmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/pathmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/mapiconmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/usermousepositionmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/mountableareamapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/floorunionmapobjectgroup.js',
'resources/assets/js/custom/mapobjectgroups/floorunionareamapobjectgroup.js',
// Depends on the above
'resources/assets/js/custom/mapobjectgroups/mapobjectgroupmanager.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmanager.js',
'resources/assets/js/custom/enemyforces/enemyforcesmanager.js',
// Map Context
'resources/assets/js/custom/mapcontext/mapcontext.js',
'resources/assets/js/custom/mapcontext/mapcontextdungeonroute.js',
'resources/assets/js/custom/mapcontext/mapcontextlivesession.js',
'resources/assets/js/custom/mapcontext/mapcontextmappingversion.js',
'resources/assets/js/custom/mapcontext/mapcontextmappingversionedit.js',
'resources/assets/js/custom/mapcontext/mapcontextdungeonexplore.js',
// Depends on map object groups + Map Context
'resources/assets/js/custom/statemanager.js',
// Echo objects
'resources/assets/js/custom/echo/echouser.js',
'resources/assets/js/custom/echo/echo.js',
// Echo messages
'resources/assets/js/custom/echo/message/message.js',
'resources/assets/js/custom/echo/message/modelmessage.js',
'resources/assets/js/custom/echo/message/listen/livesession/invite.js',
'resources/assets/js/custom/echo/message/listen/livesession/stop.js',
'resources/assets/js/custom/echo/message/listen/models/brushline/changed.js',
'resources/assets/js/custom/echo/message/listen/models/brushline/deleted.js',
'resources/assets/js/custom/echo/message/listen/models/killzone/changed.js',
'resources/assets/js/custom/echo/message/listen/models/killzone/deleted.js',
'resources/assets/js/custom/echo/message/listen/models/mapicon/changed.js',
'resources/assets/js/custom/echo/message/listen/models/mapicon/deleted.js',
'resources/assets/js/custom/echo/message/listen/models/npc/changed.js',
'resources/assets/js/custom/echo/message/listen/models/npc/deleted.js',
'resources/assets/js/custom/echo/message/listen/models/overpulledenemy/changed.js',
'resources/assets/js/custom/echo/message/listen/models/overpulledenemy/deleted.js',
'resources/assets/js/custom/echo/message/listen/models/path/changed.js',
'resources/assets/js/custom/echo/message/listen/models/path/deleted.js',
'resources/assets/js/custom/echo/message/listen/usercolorchanged.js',
'resources/assets/js/custom/echo/message/whisper/viewport.js',
'resources/assets/js/custom/echo/message/whisper/mouseposition.js',
'resources/assets/js/custom/echo/message/messagefactory.js',
// Echo message handlers
'resources/assets/js/custom/echo/messagehandler/messagehandler.js',
'resources/assets/js/custom/echo/messagehandler/listen/livesession/invite.js',
'resources/assets/js/custom/echo/messagehandler/listen/livesession/stop.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/basemodelhandler.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/modelchangedhandler.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/modeldeletedhandler.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/brushline/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/brushline/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/killzone/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/killzone/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/mapicon/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/mapicon/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/npc/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/npc/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/overpulledenemy/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/overpulledenemy/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/path/changed.js',
'resources/assets/js/custom/echo/messagehandler/listen/models/path/deleted.js',
'resources/assets/js/custom/echo/messagehandler/listen/usercolorchanged.js',
'resources/assets/js/custom/echo/messagehandler/whisper/whispermessagehandler.js',
'resources/assets/js/custom/echo/messagehandler/whisper/viewport.js',
'resources/assets/js/custom/echo/messagehandler/whisper/mouseposition.js',
// Depends on Echo
'resources/assets/js/custom/dungeonmap.js',
'resources/assets/js/custom/hotkeys.js',
// Models
'resources/assets/js/custom/models/static/mapicontype.js',
'resources/assets/js/custom/models/static/spell.js',
'resources/assets/js/custom/models/attribute.js',
'resources/assets/js/custom/models/mapobject.js',
'resources/assets/js/custom/models/versionablemapobject.js',
'resources/assets/js/custom/models/polyline.js',
'resources/assets/js/custom/models/enemy.js',
'resources/assets/js/custom/models/pridefulenemy.js',
'resources/assets/js/custom/models/enemypatrol.js',
'resources/assets/js/custom/models/enemypack.js',
'resources/assets/js/custom/models/path.js',
'resources/assets/js/custom/models/killzone.js',
'resources/assets/js/custom/models/killzonepath.js',
'resources/assets/js/custom/models/icon.js',
'resources/assets/js/custom/models/mapicon.js',
'resources/assets/js/custom/models/mapiconawakenedobelisk.js',
'resources/assets/js/custom/models/dungeonfloorswitchmarker.js',
'resources/assets/js/custom/models/brushline.js',
'resources/assets/js/custom/models/usermouseposition.js',
'resources/assets/js/custom/models/mountablearea.js',
'resources/assets/js/custom/input/usermousepositionplayer.js',
'resources/assets/js/custom/mapstate/mapstate.js',
'resources/assets/js/custom/mapstate/editmapstate.js',
'resources/assets/js/custom/mapstate/deletemapstate.js',
'resources/assets/js/custom/mapstate/pathermapstate.js',
'resources/assets/js/custom/mapstate/mapobjectmapstate.js',
'resources/assets/js/custom/mapstate/addkillzonemapstate.js',
'resources/assets/js/custom/mapstate/addawakenedobeliskgatewaymapstate.js',
'resources/assets/js/custom/mapstate/raidmarkerselectmapstate.js',
'resources/assets/js/custom/mapstate/enemyselection/enemyselection.js',
'resources/assets/js/custom/mapstate/enemyselection/editkillzoneenemyselection.js',
'resources/assets/js/custom/mapstate/enemyselection/enemypatrolenemyselection.js',
'resources/assets/js/custom/mapstate/enemyselection/mdtenemyselection.js',
'resources/assets/js/custom/mapstate/enemyselection/selectkillzoneenemyselectionoverpull.js',
'resources/assets/js/custom/mapstate/enemyselection/viewkillzoneenemyselection.js',
'resources/assets/js/custom/enemyvisuals/enemyvisual.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualicon.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmain.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainenemyclass.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainenemyforces.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainenemyportrait.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainenemyskippable.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainmdt.js',
'resources/assets/js/custom/enemyvisuals/enemyvisualmainnpctype.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifier.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifieractiveaura.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifierclassification.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifierraidmarker.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifierteeming.js',
'resources/assets/js/custom/enemyvisuals/modifiers/modifiertruesight.js',
'resources/assets/js/custom/mapcontrols/mapcontrol.js',
'resources/assets/js/custom/mapcontrols/addisplaycontrols.js',
'resources/assets/js/custom/mapcontrols/drawcontrols.js',
'resources/assets/js/custom/mapcontrols/dungeonspeedrunrequirednpcscontrols.js',
'resources/assets/js/custom/mapcontrols/echocontrols.js',
'resources/assets/js/custom/mapcontrols/enemyforcescontrols.js',
'resources/assets/js/custom/mapcontrols/enemyvisualcontrols.js',
'resources/assets/js/custom/mapcontrols/factiondisplaycontrols.js',
'resources/assets/js/custom/admin/enemyattaching.js',
'resources/assets/js/custom/admin/admindungeonmap.js',
'resources/assets/js/custom/admin/adminenemy.js',
'resources/assets/js/custom/admin/adminenemypack.js',
'resources/assets/js/custom/admin/adminenemypatrol.js',
'resources/assets/js/custom/admin/adminfloorunion.js',
'resources/assets/js/custom/admin/adminfloorunionarea.js',
'resources/assets/js/custom/admin/admindrawcontrols.js',
'resources/assets/js/custom/admin/adminpanelcontrols.js',
'resources/assets/js/custom/admin/admindungeonfloorswitchmarker.js',
'resources/assets/js/custom/admin/adminmapicon.js',
'resources/assets/js/custom/admin/adminmountablearea.js',
// Inline code
'resources/assets/js/custom/inline/inlinemanager.js',
'resources/assets/js/custom/inline/inlinecode.js',
// All inline code last
'resources/assets/js/custom/inline/*/**/*.js',
];
// Output of files
// Custom processing only
mix.styles(['resources/assets/css/**/*.css'], `public/css/custom-${version}.css`);
// Do not translate in development
if (mix.inProduction()) {
mix.babel(scripts, `public/js/custom-${version}.js`);
} else {
mix.scripts(scripts, `public/js/custom-${version}.js`);
}
mix.js('resources/assets/js/app.js', `public/js/app-${version}.js`)
.sass('resources/assets/sass/app.scss', `public/css/app-${version}.css`)
.sass('resources/assets/sass/theme/theme.scss', `public/css/theme-${version}.css`)
.sass('resources/assets/sass/home.scss', `public/css/home-${version}.css`)
.sass('resources/assets/sass/custom/custom.scss', `public/css/custom-compiled-${version}.css`)
// Lib processing
// .styles(['resources/assets/lib/**/*.css'], `public/css/lib-${version}.css`)
.babel('resources/assets/lib/**/*.js', `public/js/lib-${version}.js`);
mix.sourceMaps();
if (images) {
// if (mix.inProduction()) {
// Copies all tiles as well which takes a while
// mix.copy('resources/assets/images', 'public/images');
// } else {
// Allow import of pure JS
// mix.copy('resources/assets/js/custom', 'public/js/custom');
mix.copy('resources/assets/images/affixes', 'public/images/affixes');
mix.copy('resources/assets/images/classes', 'public/images/classes');
mix.copy('resources/assets/images/dungeons', 'public/images/dungeons');
mix.copy('resources/assets/images/echo', 'public/images/echo');
mix.copy('resources/assets/images/enemyclasses', 'public/images/enemyclasses');
mix.copy('resources/assets/images/enemyclassifications', 'public/images/enemyclassifications');
mix.copy('resources/assets/images/enemymodifiers', 'public/images/enemymodifiers');
mix.copy('resources/assets/images/enemyportraits', 'public/images/enemyportraits');
mix.copy('resources/assets/images/enemytypes', 'public/images/enemytypes');
mix.copy('resources/assets/images/expansions', 'public/images/expansions');
mix.copy('resources/assets/images/external', 'public/images/external');
mix.copy('resources/assets/images/factions', 'public/images/factions');
mix.copy('resources/assets/images/flags', 'public/images/flags');
mix.copy('resources/assets/images/gameversions', 'public/images/gameversions');
mix.copy('resources/assets/images/home', 'public/images/home');
mix.copy('resources/assets/images/icon', 'public/images/icon');
mix.copy('resources/assets/images/lib', 'public/images/lib');
mix.copy('resources/assets/images/logo', 'public/images/logo');
mix.copy('resources/assets/images/mapicon', 'public/images/mapicon');
mix.copy('resources/assets/images/oauth', 'public/images/oauth');
mix.copy('resources/assets/images/raidmarkers', 'public/images/raidmarkers');
mix.copy('resources/assets/images/routeattributes', 'public/images/routeattributes');
mix.copy('resources/assets/images/specializations', 'public/images/specializations');
mix.copy('resources/assets/images/spells', 'public/images/spells');
// }
}