如何创建 makefile 来编译 JavaScript?

发布于 2024-12-02 15:57:57 字数 283 浏览 1 评论 0原文

我如何(以及我需要什么工具)创建一个 makefile:

  • 组合所有 JavaScript '/js/*.js'(以手动顺序 - 可能使用 cat)
  • 验证组合脚本是否适用于单元测试(使用 qUnit )
  • 缩小 JavaScript
  • 验证缩小的脚本是否适用于相同的单元测试

我希望 makefile 在 Mac OS 命令行上工作。

我将把 Makefile 上传到 GitHub 存储库,因此我希望其他开发人员能够轻松使用它。

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 uploading the Makefile to a GitHub repository, so I would like something that other developers will be able to use easily.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自由范儿 2024-12-09 15:57:57

您可以从以下一个复杂的脚本中寻找灵感:

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

(另请参阅自述文件)

通常总是存在特定于项目的用例,并且一种解决方案并不适合每个项目,因此每个人都在编写临时脚本。另外,makefile 最终还是相当有限的——我建议选择一个真正的脚本工具。

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.

一抹苦笑 2024-12-09 15:57:57

感谢您的所有建议,这是我决定采用的解决方案:

  • Makefiles - 就像
  • Google V8 的快捷方式 - 从命令行执行 JavaScript

我可以使用 JavaScript 轻松执行缩小和单元测试。

我对 V8 附带并在 OS X 上编译的示例 shell 应用程序做了一些小的更改(增加了写入文件的能力)。我计划以某种方式对 32 位和 64 位的 OS X 和 Windows 进行交叉编译。我将在 GitHub 存储库中包含 V8 的二进制文件和自定义应用程序源代码。我将为那些想要定制或重新编译的人提供获取和编译 V8 的说明。

V8 将完成所有工作(本质上)。虽然我还没有将所有这些东西整合在一起,但我相信这应该可行。

唯一的缺点是基于 DOM 的单元测试无法自动化。或许可以从 Chromium 项目中获取 DOM 内容,但这可能会太耗时。我会将其留给热心的贡献者(如果有人愿意的话)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文