I want to press javascript in yui pressor, How to write Make file for press javascript.
Because grammar is difficult and does not understand it, Could you give me a sample Makefile for me?
I want to press javascript in yui pressor, How to write Make file for press javascript.
Because grammar is difficult and does not understand it, Could you give me a sample Makefile for me?
Share Improve this question edited Aug 5, 2009 at 2:47 hughdbrown 49.1k20 gold badges88 silver badges111 bronze badges asked Jun 17, 2009 at 2:53 freddiefujiwarafreddiefujiwara 59.1k28 gold badges78 silver badges109 bronze badges 3- I honestly don't know why anyone bothers with this anymore. Just serve your JS with gzip encoding and be done with it. Gzip will press text very effectively. – SpliFF Commented Jun 17, 2009 at 2:59
- Of course I expect the effect to transfer efficiency. In addition I expect the effect of the slight difficulty reading my js codes. – freddiefujiwara Commented Jun 17, 2009 at 3:17
- 3 @SpliFF: because minification makes gzip more efficient. It makes a difference if you're stuck with some large bloated JS framework... – Kornel Commented Jun 17, 2009 at 21:49
1 Answer
Reset to default 10Your makefile would look something like
code.pressed.js: code.js
pressor -o $@ $<
Note that the second line is indented with a tab character, not just spaces. The make utility cares about this.
code.pressed.js
is the name that the file should be written to, code.js
is the file to press, and pressor
is the program doing the pression.
The -o
flag indicates the output file, following the convention of pilers and similar tools. Yours may differ; check its documentation.
The variable $@
is Makefile shorthand for "this rule's target", code.pressed.js
in this case. Similarly, $<
is an abbreviation for "this rule's first dependency". These variables are useful so that you needn't repeat yourself, nor make duplicate changes when files get renamed.
If you have multiple files that will all be pressed into a single output file, you can put them all on the dependency line, and then use the special variable $^
in the build rule to specify all of them:
code.pressed.js: code1.js code2.js
pressor -o $@ $^
Alternately, if you want them each pressed separately, you can write a pattern rule and use it for all of them:
TARGETS = code1.cjs code2.cjs code3.cjs
all: $(TARGETS)
%.cjs: %.js
pressor -o $@ $<
Make defaults to building the first target that it sees, which is all
in this case. The list of files to press to is given by the contents of the TARGET
variable. The %
is a wildcard that make will substitute to generate rules for matching source and target file names.