www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Gruntfile.js (14560B)


      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       // ## Misc.
    248       miscConfig: [
    249         "config/local",
    250         "unpacked/config/local",
    251         "config/Accessible-full.js",
    252         "unpacked/config/Accessible-full.js",
    253         "config/Accessible.js",
    254         "unpacked/config/Accessible.js",
    255         //"config/default.js",
    256         //"unpacked/config/default.js",
    257         "config/Safe.js",
    258         "unpacked/config/Safe.js"
    259       ],
    260       fullConfig: [
    261         "config/*-full.js"
    262       ],
    263       restConfig: [
    264         "config/AM_CHTML.js",
    265         "config/AM_HTMLorMML.js",
    266         "config/AM_SVG.js",
    267         //"config/default.js",
    268         "config/MML_CHTML.js",
    269         "config/MML_HTMLorMML.js",
    270         "config/MMLorHTML.js",
    271         "config/MML_SVG.js",
    272         "config/TeX-AMS_CHTML.js",
    273         "config/TeX-AMS_HTML.js",
    274         "config/TeX-AMS-MML_HTMLorMML.js",
    275         "config/TeX-AMS-MML_SVG.js",
    276         "config/TeX-AMS_SVG.js",
    277         "config/TeX-MML-AM_CHTML.js",
    278         "config/TeX-MML-AM_HTMLorMML.js",
    279         "config/TeX-MML-AM_SVG.js"
    280       ],
    281       a11yExtensions: [
    282         "extensions/AssistiveMML.js",
    283         "unpacked/extensions/AssistiveMML.js"
    284       ],
    285       miscExtensions: [
    286         "extensions/FontWarnings.js",
    287         "extensions/HelpDialog.js",
    288         "extensions/MatchWebFonts.js",
    289         "extensions/MathEvents.js",
    290         "extensions/MathMenu.js",
    291         "extensions/MathZoom.js",
    292         "extensions/Safe.js",
    293         "extensions/CHTML-preview.js",
    294         //        "extensions/toMathML.js",  // only remove `toMathML.js` if you know exactly what you are doing.
    295         "unpacked/extensions/FontWarnings.js",
    296         "unpacked/extensions/HelpDialog.js",
    297         "unpacked/extensions/MatchWebFonts.js",
    298         "unpacked/extensions/MathEvents.js",
    299         "unpacked/extensions/MathMenu.js",
    300         "unpacked/extensions/MathZoom.js",
    301         "unpacked/extensions/Safe.js",
    302         "unpacked/extensions/CHTML-preview.js"
    303         //        "unpacked/extensions/toMathML.js",  // only remove `toMathML.js` if you know exactly what you are doing.
    304       ],
    305       images: [
    306         "images" // these are used in the menu. Removing them will give you 404 errors but nothing will break.
    307       ],
    308       notcode: [
    309         //".gitignore",
    310         "docs",
    311         "test",
    312         "CONTRIBUTING.md",
    313         "README-branch.txt",
    314         "README.md",
    315         "bower.json",
    316         "composer.json",
    317         ".npmignore",
    318         "package.json",
    319         ".travis.yml"
    320       ]
    321     },
    322     "regex-replace": {
    323       // disable image fonts in default HTML-CSS config
    324       noImageFont: {
    325           src: ['unpacked/jax/output/HTML-CSS/config.js',
    326 		'config/default.js'],
    327         actions: [
    328           {
    329             name: 'nullImageFont',
    330             search: /imageFont:[^,]+,/,
    331             replace: 'imageFont: null,',
    332           }
    333         ]
    334       }
    335     }
    336   });
    337 
    338   grunt.loadNpmTasks("grunt-contrib-clean");
    339   grunt.loadNpmTasks('grunt-regex-replace');
    340 
    341   grunt.registerTask("component", [
    342     // components-mathjax excludes only PNG fonts
    343     "regex-replace:noImageFont",
    344     "clean:png",
    345   ]);
    346 
    347   grunt.registerTask("template", [
    348     // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
    349     //
    350     //      Early choices.
    351     "clean:unpacked",
    352     "clean:packed", // pick one -- packed for production, unpacked for development.
    353     "clean:allConfigs", // if you do not need any combined configuration files.
    354     //      Fonts. Pick at least one! Check notes above on configurations.
    355     "clean:fontAsana",
    356     "clean:fontGyrePagella",
    357     "clean:fontGyreTermes",
    358     "clean:fontLatinModern",
    359     "clean:fontNeoEuler",
    360     "clean:fontStix",
    361     "clean:fontStixWeb",
    362     "clean:fontTeX",
    363     //      Font formats. Pick at least one (unless you use SVG output; then clean all).
    364     "clean:dropFonts", // when using SVG output
    365     "clean:eot",
    366     "clean:otf",
    367     "clean:png",
    368     "regex-replace:noImageFont",
    369     "clean:svg",
    370     "clean:woff",
    371     //      Input. Pick at least one.
    372     "clean:asciimathInput",
    373     "clean:mathmlInput",
    374     "clean:texInput",
    375     //       Output
    376     "clean:htmlCssOutput",
    377     "clean:mathmlOutput",
    378     "clean:svgOutput",
    379     // Extensions. You probably want to leave the set matching your choices.
    380     "clean:extensionsAsciimath",
    381     "clean:extensionsMathml",
    382     "clean:extensionsTeX",
    383     "clean:extensionHtmlCss",
    384     // Other items
    385     "clean:locales",
    386     "clean:miscConfig",
    387     //        "clean:miscExtensions", // you probably want that
    388     "clean:images",
    389     "clean:notcode"
    390   ]);
    391   grunt.registerTask("racket-mini", [
    392     //      Early choices.
    393     "clean:unpacked",
    394     //        "clean:packed", // pick one -- packed for production, unpacked for development.
    395     //"clean:allConfigs", // if you do not need any combined configuration files.
    396     //      Fonts. Pick at least one! Check notes above on configurations.
    397     "clean:fontAsana",
    398     "clean:fontGyrePagella",
    399     "clean:fontGyreTermes",
    400     "clean:fontLatinModern",
    401     "clean:fontNeoEuler",
    402     "clean:fontStix",
    403     //"clean:fontStixWeb",
    404     //        "clean:fontTeX",
    405     //      Font formats. Pick at least one (unless you use SVG output; then clean all).
    406     //"clean:dropFonts", // when using SVG output
    407     "clean:eot",
    408     "clean:otf",
    409     "clean:png",
    410     //"clean:svg",
    411     //"clean:woff",
    412     //      Input. Pick at least one.
    413     //"clean:asciimathInput",
    414     //"clean:mathmlInput",
    415     //"clean:texInput",
    416     //       Output
    417     //"clean:htmlCssOutput",
    418     //"clean:mathmlOutput",
    419     //        "clean:svgOutput",
    420     // Extensions. You probably want to leave the set matching your choices.
    421     //"clean:extensionsAsciimath",
    422     //"clean:extensionsMathml",
    423     //"clean:extensionsTeX",
    424     //"clean:extensionHtmlCss",
    425     // Other items
    426     // "clean:locales",
    427     "clean:miscConfig",
    428     "clean:fullConfig",
    429     "clean:restConfig",
    430     //        "clean:miscExtensions", // you probably want that
    431     //"clean:images",
    432     "clean:notcode"
    433   ]);
    434   grunt.registerTask("mjNode", [
    435     "clean:packed",
    436     "clean:allConfigs",
    437     "clean:dropFonts",
    438     "clean:htmlCssOutput",
    439     "clean:locales",
    440     "clean:miscConfig",
    441     "clean:images",
    442     "clean:notcode",
    443     "clean:miscExtensions"
    444   ]);
    445 };