MathJax Grunt Cleaner (MathJax 的简化工具)

MathJax 很强大也很庞大,如果放到自己项目中必须要进行简化,否则解压后几十兆的体积肯定会让你消化不良的。

MathJax 官网:https://www.mathjax.org/

MathJax github 地址:https://github.com/mathjax/

在 Mathjax 的 github 网址上可以很容易找到 MathJax-grunt-cleaner 工具

MathJax-grunt-cleaner 地址:https://github.com/mathjax/MathJax-grunt-cleaner

简化步骤:

  1. 下载 MathJax 完整 zip 包,解压缩(当前版本:4.7.1)
  2. 下载 MathJax-grunt-cleaner 完整 zip 包,解压缩
  3. 把 MathJax-grunt-cleaner 内的 Gruntfile.js 和 package.json 文件复制到 MathJax 解压目录
  4. 修改 MathJax 解压目录下的 Gruntfile.js 文件
    • gruntfile.js 文件使用很简单,只需要找到 'template' 任务,该模板默认清除所有内容,你对照文件根据自己的需要,屏蔽你需要保留的文件即可。(请参考本文最下方的配置文件)
  5. 执行 npm install -g grunt  安装 grunt 到全局环境 (如果你的机器上全局环境已有 grunt 请忽略此步骤)
  6. 执行 grunt template
  7. 手动删除文件
    • config/ 只保留你需要的 配置文件即可(我只留 TeX-AMS-MML_SVG)
    • extensions/a11y/  这应该是一个输入控制的扩展包,直接删掉(请慎重,仅供参考) 
    • localization/ 国际化语言文件,请保留你自己需要的内容即可。(我只留 zh-hans)

 我这里选择 TeX-AMS-MML_SVG 模式,配置如下:(仅供参考)

grunt.registerTask("template", [
    // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned).
    //
    //      Early choices.
    "clean:unpacked",
    // "clean:packed", // pick one -- packed for production, unpacked for development.
    // "clean:allConfigs", // if you do not need any combined configuration files.
    //      Fonts. Pick at least one! Check notes above on configurations.
    "clean:fontAsana",
    "clean:fontGyrePagella",
    "clean:fontGyreTermes",
    "clean:fontLatinModern",
    "clean:fontNeoEuler",
    "clean:fontStix",
    "clean:fontStixWeb",
    // "clean:fontTeX",
    //      Font formats. Pick at least one (unless you use SVG output; then clean all).
    "clean:dropFonts", // when using SVG output
    "clean:eot",
    "clean:otf",
    "clean:png",
    "clean:svg",
    "clean:woff",
    //      Input. Pick at least one.
    "clean:asciimathInput",
    // "clean:mathmlInput",
    // "clean:texInput",
    //       Output
    "clean:htmlCssOutput",
    "clean:mathmlOutput",
    // "clean:svgOutput",
    // Extensions. You probably want to leave the set matching your choices.
    "clean:extensionsAsciimath",
    "clean:extensionsMathml",
    // "clean:extensionsTeX",
    "clean:extensionHtmlCss",
    // Other items
    // "clean:locales",
    "clean:miscConfig",
    //        "clean:miscExtensions", // you probably want that
    "clean:images",
    "clean:notcode"
  ]);

 

参考文章:https://segmentfault.com/a/1190000003822609

 

转载于:https://my.oschina.net/dyhunter/blog/895665

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值