使用makefile在从coffeescript编译后合并javascript文件



我有 2 个文件。 ./main.coffee./shared.coffee .我想使用 makefile 编译两者,然后将其连接成./main.js

这是我目前拥有的:

public: main.min.js

main.min.js: main.js
uglifyjs ./main.js > ./main.min.js
#combine the shared files with the compiled main.coffee
main.js: ./main.coffee
coffee -c ./main.coffee #problem1
cat ./main.js ./shared.js > ./main.js
shared: ./shared.coffee
coffee -c ./shared.coffee

我知道这会给cat操作员带来错误。我如何编译内容并将其从标记为 problem1 的行传递给 cat 方法,而无需从中生成 main.js。

例如,coffeescript 网站给出了这个: Pipe in CoffeeScript to STDIN and get back JavaScript over STDOUT. Good for use with processes written in other languages. An example: cat src/cake.coffee | coffee -sc如何将此方法与 cat 结合使用以合并文件?

使用咖啡 --join:

main.js:
coffee -c -j main.js main.coffee shared.coffee

编辑:正如特雷弗·伯纳姆(Trevor Burnham(指出的那样,这与提问者想要的并不完全相同:

-

-join 首先合并 main.coffee 和 shared.coffee,然后编译合并的源代码。这意味着您不会获得范围分离。

最新更新