Project

General

Profile

« Previous | Next » 

Revision 1456

gruntfile

View differences:

branches/sc50/math/model/sources/math/mathjax/Gruntfile.js
1
/*
2
MathJax-grunt-cleaner
3
=====================
4
A grunt file to reduce the footprint of a MathJax installation
5

  
6
Latest version at https://github.com/pkra/MathJax-grunt-cleaner
7

  
8
Copyright (c) 2014 Mathjax Consortium
9

  
10
Permission is hereby granted, free of charge, to any person obtaining a copy
11
of this software and associated documentation files (the "Software"), to deal
12
in the Software without restriction, including without limitation the rights
13
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
copies of the Software, and to permit persons to whom the Software is
15
furnished to do so, subject to the following conditions:
16
The above copyright notice and this permission notice shall be included in
17
all copies or substantial portions of the Software.
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
THE SOFTWARE.
25
*/
26

  
27
module.exports = function(grunt) {
28
  "use strict";
29
  //   # Notes #
30
  //   NEVER remove:
31
  //
32
  //   * LICENSE -- the Apache license.
33
  //   * jax/element/mml -- this implements MathJax"s internal format. Keep either the packed or unpacked copy.
34
  //
35

  
36
  grunt.initConfig({
37
    pkg: grunt.file.readJSON("package.json"),
38
    clean: {
39
      //
40
      // ## Early choices
41
      // `unpacked` for development
42
      // ``packed` for production
43
      unpacked: [
44
        "unpacked"
45
      ],
46
      packed: [
47
        "config",
48
        "docs",
49
        "extensions",
50
        "jax",
51
        "localization",
52
        "MathJax.js"
53
      ],
54
      // If you don"t need combined configuration files or want to build your own:
55
      allConfigs: [
56
        "config",
57
        "unpacked/config"
58
      ],
59
      //
60
      // ## Choosing a font
61
      // See http://docs.mathjax.org/en/latest/font-support.html#font-configuration for background information
62
      //
63
      // 1. Remove font files and font data for fonts you won"t use.
64
      //    **IMPORTANT.** Make sure to prevent fallbacks and local fonts in your configuration!
65
      //
66
      //
67
      fontAsana: [
68
        "fonts/HTML-CSS/Asana-Math",
69
        "jax/output/HTML-CSS/fonts/Asana-Math",
70
        "unpacked/jax/output/HTML-CSS/fonts/Asana-Math",
71
        "jax/output/SVG/fonts/Asana-Math",
72
        "unpacked/jax/output/SVG/fonts/Asana-Math"
73
      ],
74
      fontGyrePagella: [
75
        "fonts/HTML-CSS/Gyre-Pagella",
76
        "jax/output/HTML-CSS/fonts/Gyre-Pagella",
77
        "unpacked/jax/output/HTML-CSS/fonts/Gyre-Pagella",
78
        "jax/output/SVG/fonts/Gyre-Pagella",
79
        "unpacked/jax/output/SVG/fonts/Gyre-Pagella"
80
      ],
81
      fontGyreTermes: [
82
        "fonts/HTML-CSS/Gyre-Termes",
83
        "jax/output/HTML-CSS/fonts/Gyre-Termes",
84
        "unpacked/jax/output/HTML-CSS/fonts/Gyre-Termes",
85
        "jax/output/SVG/fonts/Gyre-Termes",
86
        "unpacked/jax/output/SVG/fonts/Gyre-Termes"
87
      ],
88
      fontLatinModern: [
89
        "fonts/HTML-CSS/Latin-Modern",
90
        "jax/output/HTML-CSS/fonts/Latin-Modern",
91
        "unpacked/jax/output/HTML-CSS/fonts/Latin-Modern",
92
        "jax/output/SVG/fonts/Latin-Modern",
93
        "unpacked/jax/output/SVG/fonts/Latin-Modern"
94
      ],
95
      fontNeoEuler: [
96
        "fonts/HTML-CSS/Neo-Euler",
97
        "jax/output/HTML-CSS/fonts/Neo-Euler",
98
        "unpacked/jax/output/HTML-CSS/fonts/Neo-Euler",
99
        "jax/output/SVG/fonts/Neo-Euler",
100
        "unpacked/jax/output/SVG/fonts/Neo-Euler"
101
      ],
102
      fontStix: [
103
        "fonts/HTML-CSS/STIX",
104
        "jax/output/HTML-CSS/fonts/STIX",
105
        "unpacked/jax/output/HTML-CSS/fonts/STIX",
106
        "jax/output/SVG/fonts/STIX",
107
        "unpacked/jax/output/SVG/fonts/STIX"
108
      ],
109
      fontStixWeb: [
110
        "fonts/HTML-CSS/STIX-Web",
111
        "jax/output/HTML-CSS/fonts/STIX-Web",
112
        "unpacked/jax/output/HTML-CSS/fonts/STIX-Web",
113
        "jax/output/SVG/fonts/STIX-Web",
114
        "unpacked/jax/output/SVG/fonts/STIX-Web"
115
      ],
116
      fontTeX: [
117
        "fonts/HTML-CSS/TeX",
118
        "jax/output/HTML-CSS/fonts/TeX",
119
        "unpacked/jax/output/HTML-CSS/fonts/TeX",
120
        "jax/output/SVG/fonts/TeX",
121
        "unpacked/jax/output/SVG/fonts/TeX"
122
      ],
123
      //
124
      // Remove font formats
125
      // If you know you only need a specific format of your remaining fonts (e.g., woff), then you can delete the others.
126
      dropFonts: [ // if you use SVG output, you can drop all font formats (SVG output uses the data in `jax/output/SVG/fonts/...`)
127
        "fonts"
128
      ],
129
      eot: [
130
        "fonts/**/eot"
131
      ],
132
      otf: [
133
        "fonts/**/otf"
134
      ],
135
      png: [
136
        "fonts/**/png"
137
      ],
138
      svg: [ // **NOT** related to the SVG output!
139
        "fonts/**/svg"
140
      ],
141
      woff: [
142
        "fonts/**/woff"
143
      ],
144
      // ## Choose the input
145
      //    Remove input that you don"t need.
146
      //    **Note.** This includes combined configuration files.
147
      asciimathInput: [
148
        "config/AM*",
149
        "config/TeX-MML-AM*",
150
        "jax/input/AsciiMath",
151
        "unpacked/config/AM*",
152
        "unpacked/config/TeX-MML-AM*",
153
        "unpacked/jax/input/AsciiMath"
154
      ],
155
      mathmlInput: [
156
        "config/MML*",
157
        "config/TeX-MML*",
158
        "config/TeX-AMS-MML*",
159
        "jax/input/MathML",
160
        "unpacked/config/MathML*",
161
        "unpacked/jax/input/MathML"
162
      ],
163
      texInput: [
164
        "config/TeX*",
165
        "jax/input/TeX",
166
        "unpacked/config/TeX*",
167
        "unpacked/jax/input/TeX"
168
      ],
169
      // ## Extensions
170
      extensionsAsciimath: [
171
        "extensions/asciimath2jax.js",
172
        "unpacked/extensions/asciimath2jax.js"
173
      ],
174
      extensionsMathml: [
175
        "extensions/MathML",
176
        "extensions/mml2jax.js",
177
        "unpacked/extensions/MathML",
178
        "unpacked/extensions/mml2jax.js"
179
      ],
180
      extensionsTeX: [
181
        "extensions/TeX",
182
        "extensions/jsMath2jax.js",
183
        "extensions/tex2jax.js",
184
        "unpacked/extensions/TeX",
185
        "unpacked/extensions/jsMath2jax.js",
186
        "unpacked/extensions/tex2jax.js"
187
      ],
188
      extensionHtmlCss: [
189
        "extensions/HTML-CSS",
190
        "unpacked/extensions/HTML-CSS"
191
      ],
192
      // ## Choose Output
193
      htmlCssOutput: [
194
        "config/*HTMLorMML.js",
195
        "config/*HTMLorMML-full.js",
196
        "unpacked/config/*HTMLorMML.js",
197
        "unpacked/config/*HTMLorMML-full.js",
198
        "jax/output/HTML-CSS",
199
        "unpacked/jax/output/HTML-CSS"
200
      ],
201
      mathmlOutput: [
202
        "config/*HTMLorMML.js",
203
        "config/*HTMLorMML-full.js",
204
        "unpacked/config/*HTMLorMML.js",
205
        "unpacked/config/*HTMLorMML-full.js",
206
        "jax/output/NativeMML",
207
        "unpacked/jax/output/NativeMML"
208
      ],
209
      svgOutput: [
210
        "config/*SVG.js",
211
        "config/*SVG-full.js",
212
        "unpacked/config/*SVG.js",
213
        "unpacked/config/*SVG-full.js",
214
        "jax/output/SVG",
215
        "unpacked/jax/output/SVG"
216
      ],
217
      commonHtmlOutput: [
218
        "configs/*CHTML.js",
219
        "configs/*CHTML-full.js",
220
        "unpacked/config/*CHTML.js",
221
        "unpacked/configs/*CHTML-full.js",
222
        "jax/output/CommonHTML",
223
        "unpacked/jax/output/CommonHTML",
224
        "extensions/CHTML-preview.js",
225
        "unpacked/extensions/CHTML-preview.js"
226
      ],
227
      previewHtmlOutput: [
228
        "jax/output/PreviewHTML",
229
        "unpacked/jax/output/PreviewHTML",
230
        "extensions/fast-preview.js",
231
        "unpacked/extensions/fast-preview.js",
232
        "extensions/CHTML-preview.js",
233
        "unpacked/extensions/CHTML-preview.js"
234
      ],
235
      plainSourceOutput: [
236
        "jax/output/PlainSource",
237
        "unpacked/jax/output/PlainSource"
238
      ],
239
      //  ## Locales
240
      //  Removes all locale files. Change this as needed to keep your preferred language.
241
      //  **NOTE.** English strings are hardcoded.
242
      //  **NOTE.** If you fix the locale, drop the menu entry: http://docs.mathjax.org/en/latest/options/MathMenu.html#configure-mathmenu
243
      locales: [
244
        "localization",
245
        "unpacked/localization"
246
      ],
247
      localesEsFr: [
248
        "localization/ar",
249
        "localization/ast",
250
        "localization/bcc",
251
        "localization/bg",
252
        "localization/br",
253
        "localization/ca",
254
        "localization/cdo",
255
        "localization/ce",
256
        "localization/cs",
257
        "localization/cy",
258
        "localization/da",
259
        "localization/de",
260
        "localization/diq",
261
        "localization/eo",
262
        "localization/fa",
263
        "localization/fi",
264
        "localization/gl",
265
        "localization/he",
266
        "localization/ia",
267
        "localization/it",
268
        "localization/ja",
269
        "localization/kn",
270
        "localization/ko",
271
        "localization/lb",
272
        "localization/lki",
273
        "localization/lt",
274
        "localization/mk",
275
        "localization/nl",
276
        "localization/oc",
277
        "localization/pl",
278
        "localization/pt",
279
        "localization/pt-br",
280
        "localization/qqq",
281
        "localization/ru",
282
        "localization/scn",
283
        "localization/sco",
284
        "localization/sk",
285
        "localization/sl",
286
        "localization/sv",
287
        "localization/th",
288
        "localization/tr",
289
        "localization/uk",
290
        "localization/vi",
291
        "localization/zh-hans",
292
        "localization/zh-hant",
293
        "unpacked/localization"
294
      ],
295
      // ## Misc.
296
      miscConfig: [
297
        "config/local",
298
        "unpacked/config/local",
299
        "config/Accessible-full.js",
300
        "unpacked/config/Accessible-full.js",
301
        "config/Accessible.js",
302
        "unpacked/config/Accessible.js",
303
        "config/default.js",
304
        "unpacked/config/default.js",
305
        "config/Safe.js",
306
        "unpacked/config/Safe.js"
307
      ],
308
      a11y: [
309
        "extensions/a11y"
310
      ],
311
      a11yExtensions: [
312
        "extensions/AssistiveMML.js",
313
        "unpacked/extensions/AssistiveMML.js"
314
      ],
315
      miscExtensions: [
316
        "extensions/FontWarnings.js",
317
        "extensions/HelpDialog.js",
318
        "extensions/MatchWebFonts.js",
319
        "extensions/MathEvents.js",
320
        "extensions/MathMenu.js",
321
        "extensions/MathZoom.js",
322
        "extensions/Safe.js",
323
        "extensions/CHTML-preview.js",
324
        //        "extensions/toMathML.js",  // only remove `toMathML.js` if you know exactly what you are doing.
325
        "unpacked/extensions/FontWarnings.js",
326
        "unpacked/extensions/HelpDialog.js",
327
        "unpacked/extensions/MatchWebFonts.js",
328
        "unpacked/extensions/MathEvents.js",
329
        "unpacked/extensions/MathMenu.js",
330
        "unpacked/extensions/MathZoom.js",
331
        "unpacked/extensions/Safe.js",
332
        "unpacked/extensions/CHTML-preview.js"
333
        //        "unpacked/extensions/toMathML.js",  // only remove `toMathML.js` if you know exactly what you are doing.
334
      ],
335
      images: [
336
        "images" // these are used in the menu. Removing them will give you 404 errors but nothing will break.
337
      ],
338
      notcode: [
339
        ".gitignore",
340
        "docs",
341
        "test",
342
        "CONTRIBUTING.md",
343
        "README-branch.txt",
344
        "README.md",
345
        "bower.json",
346
        "composer.json",
347
        ".npmignore",
348
        "package.json"
349
      ]
350
    },
351
    "regex-replace": {
352
      // disable image fonts in default HTML-CSS config
353
      noImageFont: {
354
        src: ['unpacked/jax/output/HTML-CSS/config.js'],
355
        actions: [
356
          {
357
            name: 'nullImageFont',
358
            search: /imageFont:[^,]+,/,
359
            replace: 'imageFont: null,',
360
          }
361
        ]
362
      }
363
    }
364
  });
365

  
366
  grunt.loadNpmTasks("grunt-contrib-clean");
367
  grunt.loadNpmTasks('grunt-regex-replace');
368

  
369
  grunt.registerTask("component", [
370
    // components-mathjax excludes only PNG fonts
371
    "regex-replace:noImageFont",
372
    "clean:png",
373
  ]);
374

  
375
  grunt.registerTask("template", [
376
    // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
377
    //
378
    //      Early choices.
379
    "clean:unpacked",
380
    "clean:packed", // pick one -- packed for production, unpacked for development.
381
    "clean:allConfigs", // if you do not need any combined configuration files.
382
    //      Fonts. Pick at least one! Check notes above on configurations.
383
    "clean:fontAsana",
384
    "clean:fontGyrePagella",
385
    "clean:fontGyreTermes",
386
    "clean:fontLatinModern",
387
    "clean:fontNeoEuler",
388
    "clean:fontStix",
389
    "clean:fontStixWeb",
390
    "clean:fontTeX",
391
    //      Font formats. Pick at least one (unless you use SVG output; then clean all).
392
    "clean:dropFonts", // when using SVG output
393
    "clean:eot",
394
    "clean:otf",
395
    "clean:png",
396
    "clean:svg",
397
    "clean:woff",
398
    //      Input. Pick at least one.
399
    "clean:asciimathInput",
400
    "clean:mathmlInput",
401
    "clean:texInput",
402
    //       Output
403
    "clean:htmlCssOutput",
404
    "clean:mathmlOutput",
405
    "clean:svgOutput",
406
    // Extensions. You probably want to leave the set matching your choices.
407
    "clean:extensionsAsciimath",
408
    "clean:extensionsMathml",
409
    "clean:extensionsTeX",
410
    "clean:extensionHtmlCss",
411
    // Other items
412
    "clean:locales",
413
    "clean:miscConfig",
414
    //        "clean:miscExtensions", // you probably want that
415
    "clean:images",
416
    "clean:notcode"
417
  ]);
418
   grunt.registerTask("scenari-web", [
419
    // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
420
    //
421
    //      Early choices.
422
    "clean:unpacked",
423
    //"clean:packed", // pick one -- packed for production, unpacked for development.
424
    "clean:allConfigs", // if you do not need any combined configuration files.
425
    //      Fonts. Pick at least one! Check notes above on configurations.
426
    "clean:fontAsana",
427
    "clean:fontGyrePagella",
428
    "clean:fontGyreTermes",
429
    "clean:fontLatinModern",
430
    "clean:fontNeoEuler",
431
    "clean:fontStix",
432
    "clean:fontStixWeb",
433
    //"clean:fontTeX",
434
    //      Font formats. Pick at least one (unless you use SVG output; then clean all).
435
    "clean:dropFonts", // when using SVG output
436
    "clean:eot",
437
    "clean:otf",
438
    "clean:png",
439
    "clean:svg",
440
    "clean:woff",
441
    //      Input. Pick at least one.
442
    "clean:asciimathInput",
443
    //"clean:mathmlInput",
444
    //"clean:texInput",
445
    //       Output
446
    //"clean:htmlCssOutput",
447
    //"clean:mathmlOutput",
448
    //"clean:svgOutput",
449
    "clean:commonHtmlOutput",
450
    // Extensions. You probably want to leave the set matching your choices.
451
    "clean:extensionsAsciimath",
452
    //"clean:extensionsMathml",
453
    //"clean:extensionsTeX",
454
    //"clean:extensionHtmlCss",
455
    // Other items
456
    "clean:a11y",
457
    //"clean:a11yExtensions",
458
    "clean:localesEsFr",
459
    "clean:miscConfig",
460
    //        "clean:miscExtensions", // you probably want that
461
    "clean:images",
462
    "clean:notcode"
463
  ]);
464
   grunt.registerTask("scenari-a11y", [
465
    // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
466
    //
467
    //      Early choices.
468
    "clean:unpacked",
469
    //"clean:packed", // pick one -- packed for production, unpacked for development.
470
    "clean:allConfigs", // if you do not need any combined configuration files.
471
    //      Fonts. Pick at least one! Check notes above on configurations.
472
    "clean:fontAsana",
473
    "clean:fontGyrePagella",
474
    "clean:fontGyreTermes",
475
    "clean:fontLatinModern",
476
    "clean:fontNeoEuler",
477
    "clean:fontStix",
478
    "clean:fontStixWeb",
479
    //"clean:fontTeX",
480
    //      Font formats. Pick at least one (unless you use SVG output; then clean all).
481
    "clean:dropFonts", // when using SVG output
482
    "clean:eot",
483
    "clean:otf",
484
    "clean:png",
485
    "clean:svg",
486
    "clean:woff",
487
    //      Input. Pick at least one.
488
    "clean:asciimathInput",
489
    //"clean:mathmlInput",
490
    //"clean:texInput",
491
    //       Output
492
    //"clean:htmlCssOutput",
493
    //"clean:mathmlOutput",
494
    //"clean:svgOutput",
495
    "clean:commonHtmlOutput",
496
    // Extensions. You probably want to leave the set matching your choices.
497
    "clean:extensionsAsciimath",
498
    //"clean:extensionsMathml",
499
    //"clean:extensionsTeX",
500
    //"clean:extensionHtmlCss",
501
    // Other items
502
    //"clean:a11y",
503
    "clean:a11yExtensions",
504
    "clean:localesEsFr",
505
    "clean:miscConfig",
506
    //        "clean:miscExtensions", // you probably want that
507
    "clean:images",
508
    "clean:notcode"
509
  ]);
510
   grunt.registerTask("scenari-print", [
511
    // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
512
    //
513
    //      Early choices.
514
    "clean:unpacked",
515
    //"clean:packed", // pick one -- packed for production, unpacked for development.
516
    "clean:allConfigs", // if you do not need any combined configuration files.
517
    //      Fonts. Pick at least one! Check notes above on configurations.
518
    "clean:fontAsana",
519
    "clean:fontGyrePagella",
520
    "clean:fontGyreTermes",
521
    "clean:fontLatinModern",
522
    "clean:fontNeoEuler",
523
    "clean:fontStix",
524
    "clean:fontStixWeb",
525
    //"clean:fontTeX",
526
    //      Font formats. Pick at least one (unless you use SVG output; then clean all).
527
    "clean:dropFonts", // when using SVG output
528
    "clean:eot",
529
    "clean:otf",
530
    "clean:png",
531
    "clean:svg",
532
    "clean:woff",
533
    //      Input. Pick at least one.
534
    "clean:asciimathInput",
535
    //"clean:mathmlInput",
536
    //"clean:texInput",
537
    //       Output
538
    "clean:htmlCssOutput",
539
    "clean:mathmlOutput",
540
    "clean:svgOutput",
541
    //"clean:commonHtmlOutput",
542
    // Extensions. You probably want to leave the set matching your choices.
543
    "clean:extensionsAsciimath",
544
    //"clean:extensionsMathml",
545
    //"clean:extensionsTeX",
546
    //"clean:extensionHtmlCss",
547
    // Other items
548
    "clean:a11y",
549
    "clean:a11yExtensions",
550
    "clean:locales",
551
    "clean:miscConfig",
552
    "clean:miscExtensions", // you probably want that
553
    "clean:images",
554
    "clean:notcode"
555
  ]);
556
  grunt.registerTask("mjNode", [
557
    "clean:packed",
558
    "clean:allConfigs",
559
    "clean:dropFonts",
560
    "clean:htmlCssOutput",
561
    "clean:locales",
562
    "clean:miscConfig",
563
    "clean:images",
564
    "clean:notcode",
565
    "clean:miscExtensions"
566
  ]);
567
};

Also available in: Unified diff