Makefile that compresses javascript

I want to compress javascript in yui compressor. How to write Make file for javascript compression.

Since the grammar is complex and does not understand it, could you give me a sample makefile for me?

+5
source share
1 answer

Your makefile will look something like this:

code.compressed.js: code.js
    compressor -o $@ $<

Note that the second line is indented with a tab character, not just spaces. The make utility takes care of this.

code.compressed.js- this is the name into which the file should be written, code.js- this is the file for compression, and compressor- the program that performs the compression.

-o , . ; .

$@ Makefile " ", code.compressed.js . , $< " ". , .

, , , $^ , :

code.compressed.js: code1.js code2.js
    compressor -o $@ $^

, , , :

TARGETS = code1.cjs code2.cjs code3.cjs

all: $(TARGETS)

%.cjs: %.js
    compressor -o $@ $<

, , all. TARGET. % - , .

+10

All Articles