简体   繁体   English

如何使用Eclipse JSDT缩小JavaScript文件?

[英]how to minify JavaScript files using Eclipse JSDT?

如何使用Eclipse JSDT(JavaScript开发工具)“构建” *.min.js*.min.js.map文件?

You can use an external builder to run build scripts for your Javascript tasks. 您可以使用外部构建器来运行Javascript任务的构建脚本。

Go to Project --> Properties and choose Builders. 转到项目->属性,然后选择生成器。 Then you can add an external builder to launch an external program with whatever arguments you need. 然后,您可以添加外部构建器以使用所需的任何参数启动外部程序。

为NPM设置外部构建器

You can se the builder to run automatically by using the Build Options tab and setting the "Run The Builder:" options: 您可以通过使用“构建选项”选项卡并设置“运行构建器:”选项来使构建器自动运行:

在此处输入图片说明

I use YUICompressor . 我使用YUICompressor It works on both JavaScript and CSS. 它同时适用于JavaScript和CSS。 Once it's installed, it's easy to use: 安装完成后,很容易使用:

  1. Right-click the JS file you'd like to minimize 右键单击要最小化的JS文件
  2. Go to External Tools > Compress Javascript 转到外部工具>压缩Javascript
  3. Specify the name of the compressed file and click Finish 指定压缩文件的名称,然后单击“完成”。

Unfortunately, you will need to manually run the compressor every time you change the original file, which can get tedious if you're working with lots of files. 不幸的是,您每次更改原始文件时都需要手动运行压缩器,如果要处理大量文件,这可能会很乏味。 If you want to automate the process, see this answer . 如果要自动执行该过程,请参见此答案 I ended up writing a quick batch script for my project. 我最终为我的项目编写了一个快速批处理脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM