0

I have 2 files. ./main.coffee and ./shared.coffee. I'd like to use makefile to compile both then concatinate it into ./main.js.

This is what I currently have:

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

I know this will give an error for the cat operator. How do I just compile and pass the contents from the line labeled problem1 to the cat method without generating main.js from it.

For eg. the coffeescript site gave this: 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 how do I combine this method with cat to just merge the files?

1

1 Answer 1

1

Using coffee --join:

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

Edit: As Trevor Burnham notes, this is not exactly the same as what the asker wanted:

--join first merges main.coffee and shared.coffee, then compiles the merged source. This means that you don't get scope separation.

Sign up to request clarification or add additional context in comments.

2 Comments

This is actually different from what the asker wanted: --join first merges main.coffee and shared.coffee, then compiles the merged source. This means that you don't get scope separation.
Trevor: True, adding this caveat to the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.