0

How to "build" *.min.js and *.min.js.map files using Eclipse JSDT (JavaScript Developement Tools)?

user2449761
  • 1,169
  • 13
  • 25

2 Answers2

2

You can use an external builder to run build scripts for your Javascript tasks.

Go to Project --> Properties and choose Builders. Then you can add an external builder to launch an external program with whatever arguments you need.

Setting up an external builder for NPM

You can se the builder to run automatically by using the Build Options tab and setting the "Run The Builder:" options:

enter image description here

BCG
  • 1,170
  • 8
  • 19
  • how to add the "browserify" builder on Windows? – user2449761 Sep 30 '14 at 12:31
  • The process is the same. However instead of have a path like /usr/bin/npm though you would just use a path like C:\tools\sometool.exe ... the 'browserify' part is not really relevant to the process BTW, you can set up any external command you want for the builder. – BCG Sep 30 '14 at 12:42
  • What builder can I use on Windows? – user2449761 Sep 30 '14 at 12:44
  • You can set up a builder for whatever external you would normally use for processing your JS files... if you have something like a grunt file you could just call that, or you could use some external tool directly like http://lisperator.net/uglifyjs/ – BCG Sep 30 '14 at 13:28
  • sorry I am new to JavaScript ;/ How to use this lisperator.net/uglifyjs ? – user2449761 Sep 30 '14 at 13:37
1

I use YUICompressor. It works on both JavaScript and CSS. Once it's installed, it's easy to use:

  1. Right-click the JS file you'd like to minimize
  2. Go to External Tools > Compress 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.

Community
  • 1
  • 1
Ecliptica
  • 760
  • 2
  • 8
  • 21