CodeKit-1-Old
CodeKit-1-Old copied to clipboard
Feature Request: JS and CoffeeScript imports
I would really like to auto combine and minify compiled coffeeScript output with existing js files.
It's particular useful in cases where you're depending on non-coffeescript libraries like backbone.
@koen-serry for the time being I've been adding them as .coffee files containing
javascript. Works well enough for the moment.
Sorry I'm quite new to CodeKit, how do you do that?
It's not a CodeKit thing, its a coffeescript thing. CoffeeScript lets you use normal JavaScript so long as its between tick marks . Check the documentation here http://coffeescript.org/#embedded . So I make a blank .coffee file and then do an embed of the js I need to include. That was I can include js into coffee compiles.
+1 for the original feature request.
The trick @Fresheyeball suggested is cool, but I don't like having to modify other libraries just to use CoffeeScript.
+1 for the original feature request
Hi guys, this is already possible.
All you need to do is use an "@codekit-prepend/append" statement in your Javascript file to bring in the compiled output of your CoffeeScript file.
So, we have "fileC.coffee" that compiles to "fileC.js". Then, we have another Javascript file named "main.js". We just append/prepend "fileC.js" into "main.js".
Whenever you compile the CoffeeScript file, CodeKit will automatically re-process "main.js" so that it captures the changes.
@bdkjones hmmm.... you are right. It is possible, but that doesn't really address the feature request. Lets say the desired result is something like this inside a .coffee file:
#@codekit-prepend 'basefile.coffee' #@codekit-prepend 'ajsliberary.js' #@codekit-prepend 'dependentClass.coffee'
Now I either have resolve to have codekit compile every coffeescript file and manage dependencies in a .js file instead, which means the number of files in the application nearly doubles. Or manage cascades of growing complexity. Being able to @codekit-prepend .js files directly alongside .coffee files would offer alot of value to me for application management.
What I am doing now, turning my .js files into .coffee files by surrounding those files as embedded js. is working and more manageable than cascading coffee to js to js again.
But the problem with converting js to embedded js in coffee, is that the files cannot update from git if they come from opensource. And my IDE detects them as .coffee and does not code hint or syntax highlight the js, making working with the two formats side by side abit cumbersome. Lastly co workers, who prefer to complete their tasks in js, means I have an additional step to include it in my final compiled output.
I agree that the current method is not ideal. But there are some technical details involved in implementing what you propose that I just haven't tackled yet. I do want to get to this state at some point, though.
@bdkjones rock on.
@bdkjones while I got you here, I was considering writing an eclipse or sublime text pluggin to recognize @codekit-prepends for purpose of code hinting. But I'm not sure how to go about it yet. Would you be interested in participating?
I'm afraid I can't right now; I've got my hands full just updating CodeKit. I have some great stuff planned for the next few months! But thanks!
+1 for original request.
I recently learned that snockets on nodejs does this. Perhaps there is something in there that can be reused, perhaps not.
Can it be that the solution that @bdkjones suggests does not work in Maverick?
I have a similar javascript.coffeescript setup and codekit doesn't detect any changed in the compiled output of my coffeescript files. Every time when I updated one of my coffeescript, I have to compile my main.js by hand to bring everything together.
Sorry, I found another open issue #667 dealing with this.