Can I use CoffeeScript to combine other js files?

I'm wondering if I can use CoffeeScript to include other standard JS files (as an easy way to do some file concatenation).

I have a client side minification tool that I am using (an app called Live Reload ) that works fine.

<!-- Some jQuery plugins I'm using. -->
<script src="/js/libs/some-plugin.js"></script>
<script src="/js/libs/another-plugin.js"></script>

<!-- The output of my /js/ file: -->
<script src="/js/script.js"></script> 


What I would like to do is simply combine these plugins into the output of my coffeescript file. I looked high and low and I only saw articles on server methods for doing this, as well as many articles on things like . I am not trying to do something so complicated - I just want to get rid of a couple of round trips for js files. I know that I will never touch.

Is CoffeeScript talking about "include"?


source to share

2 answers

Basically, the answer seems to be no. This is not what CoffeeScript is capable of.



There are ways to do this by creating a more complex Cakefile

one in which you will read the contents of js files and add them to the output of the CS compiler than writing it to one target js file. You can even create a fake global function require

to mimic its behavior in a linked file.

If you were looking for a standard tool or at least an approach to this problem, unfortunately since CS is very young, not yet. There are some attempts, however: .

I am currently working on such a tool and plan to publish it within a month. Then I'll post a message.



All Articles