Makefile文件合并js文件,使一个COM pressed版本 [英] Makefile to combine js files and make a compressed version
问题描述
我试图写一个结合多种JS文件到一个单一的一个基本的makefile文件,然后做同样的,但COM presses他们。
到目前为止,我有这一项,可以使COM pressed版本的罚款。
#设置源目录
SRCDIR = SRC /#创建模块列表
模块= $ {SRCDIR} core.js \\
$ {SRCDIR} sizzle.js \\
$ {SRCDIR} json2.js \\
$ {SRCDIR} ajax.js \\
$ {SRCDIR} attribute.js \\
$ {SRCDIR} content.js \\
$ {SRCDIR} cookie.js \\
$ {SRCDIR} css.js \\
$ {SRCDIR} event.js \\
$ {SRCDIR} json.js \\
$ {SRCDIR} location.js \\
$ {SRCDIR} opacity.js \\
$ {SRCDIR} ready.js \\
$ {SRCDIR} size.js \\
$ {SRCDIR} init.js#的COM preSS所有的模块到spark.js的
spark.js:$ {}模块
Java的罐子yuicom pressor.jar -o $ @ $ ^
有谁知道我怎么会去增加一个uncom pressed版本,称为火花dev.js?我一直在尝试使用猫,但我没有得到很远。这是我写过我的第一个Makefile文件。
修改
我想这code。与猫
火花dev.js:$ {}模块
猫$ @ $ ^
您几乎没有:-)这应该工作:
火花dev.js:$ {}模块
猫> $ @ $ ^
背景:猫
的作用是(试图)打开命令行上列出的所有文件,并转储内容到标准输出。在> $ @
语法由外壳理解为创建文件 $ @
,这个命令的标准输出连接到它,所以现在我们结束与内容 $ ^
组合在一起成 $ @
。
I am trying to write a basic makefile that combines multiple js files into a single one and then does the same but compresses them.
So far I have this one that can make the compressed version fine.
# Set the source directory
srcdir = src/
# Create the list of modules
modules = ${srcdir}core.js\
${srcdir}sizzle.js\
${srcdir}json2.js\
${srcdir}ajax.js\
${srcdir}attribute.js\
${srcdir}content.js\
${srcdir}cookie.js\
${srcdir}css.js\
${srcdir}event.js\
${srcdir}json.js\
${srcdir}location.js\
${srcdir}opacity.js\
${srcdir}ready.js\
${srcdir}size.js\
${srcdir}init.js
# Compress all of the modules into spark.js
spark.js: ${modules}
java -jar yuicompressor.jar -o $@ $^
Does anyone know how I would go about adding an uncompressed version called spark-dev.js? I have been trying to use cat but I didn't get very far. This is my first makefile I have ever written.
EDIT I tried this code with cat
spark-dev.js: ${modules}
cat $@ $^
You were almost there :-) This should work:
spark-dev.js: ${modules}
cat > $@ $^
Background: The function of cat
is to (try to) open all the files listed on its command line, and dump the contents to stdout. The > $@
syntax is understood by the shell to mean "create the file $@
, and connect this command's stdout to it", so now we end up with the contents of $^
combined together into $@
.
这篇关于Makefile文件合并js文件,使一个COM pressed版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!