开发者

How to create makefile to compile JavaScripts?

How can I (and what tools do I need to) create a makefile that:

  • Combine all JavaScripts '/js/*.js' (in a manual order - possibly with cat)
  • Verify that combined script works against unit tests (which using qUnit)
  • Minify JavaScripts
  • Verify that minified script works against same unit tests

I would like makefile to work on Mac OS command line.

I will be u开发者_JAVA百科ploading the Makefile to a GitHub repository, so I would like something that other developers will be able to use easily.


Here is one complex script you could look for inspiration:

https://github.com/mobilizejs/mobilize.js/blob/master/release.py

(check also README)

Generally there are always project specific use cases and one solution does not fit every project, thus everyone is doing ad hoc scripts. Also, makefile is pretty limited in the end - I recommed to pick a real scripting tool.


Thanks for all the suggestions, here is the solution that I have decided to go with:

  • Makefiles - just as a shortcut really
  • Google V8 - to execute JavaScript from command-line

I can easily perform minification and unit testing using JavaScript.

I have made a few minor changes (added ability to write files) to the sample shell application that comes with V8 and compiled on OS X. I plan to somehow cross-compile for OS X and Windows in both 32bit and 64-bit. I will include binaries for V8 and custom application source in the GitHub repository. I will include instructions to obtain and compile V8 for those who want to customise or recompile.

V8 will be doing all of the work (essentially). Whilst I have yet to bring all of these things together, I believe that this should work.

The only downside is that DOM based unit testing cannot be automated. It might be possible to get the DOM stuff from the Chromium project, but this is probably going to be too time consuming. I'll leave that to an enthusiastic contributor (should anybody want to).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜