Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script file concatenation for better code organization #127

Closed
danielgtaylor opened this issue Oct 16, 2013 · 11 comments
Closed

Script file concatenation for better code organization #127

danielgtaylor opened this issue Oct 16, 2013 · 11 comments

Comments

@danielgtaylor
Copy link

@danielgtaylor danielgtaylor commented Oct 16, 2013

It would be nice to have a way to easily concatenate scripts so that you can split your js/coffee code into multiple files. How I would like to organize my code:

- main.js
| - main.coffee
| - users.coffee
| - utils.coffee
script(src="/main.js")

What I currently have to do:

script(src="/main.js/utils.js")
script(src="/main.js/users.js")
script(src="/main.js/main.js")

It looks like sprockets uses a special comment for this purpose:

#= include file.coffee

https://github.com/sstephenson/sprockets#the-include-directive

What are the chances of getting some kind of script preprocessing to allow this? It could potentially also be done with special folder names or JSON data files, so I'm not 100% set in the comment directive, it's just an idea. For example, any folder name that ends in .js could concatenate all files within it (but how do we manage order?).

@kennethormandy
Copy link
Collaborator

@kennethormandy kennethormandy commented Oct 17, 2013

@drhayes
Copy link

@drhayes drhayes commented Oct 19, 2013

+1 for browserify! I like Brian's idea of how to set it up.

@edrex
Copy link
Contributor

@edrex edrex commented Oct 29, 2013

+1 for Browserify, es muy elegante

not sure about the whole smart directory thing, it doesn't add any new capability vs the leading _ convention combined with Browserify (appeal to orthogonality)

@z5h
Copy link

@z5h z5h commented Nov 25, 2013

I've hacked something like this together.
See: #165
which references my example:
https://github.com/z5h/harp-start

@ncammarata
Copy link

@ncammarata ncammarata commented Dec 4, 2013

I'd just like to post that this is the one real feature that's making me switch to Grunt at the moment. Was using Harp but had way too many JS includes in my HTML.

@ncammarata
Copy link

@ncammarata ncammarata commented Jan 28, 2014

Any update on this?

@johanhalse
Copy link

@johanhalse johanhalse commented Feb 17, 2014

I've worked around this: I use Harp as a node library and wrap it with a concatenation step. I've opted for a simple solution, but I'm sure it can be done more elegantly to track changes in JS too. Me, I'm lazy and use nodemon :)

@zeke
Copy link
Contributor

@zeke zeke commented Feb 18, 2014

Browserify is an awesome and elegant way to solve this concatenation problem, and would be a great step for bringing browserify to a larger audience. I added a scrappy pull request to terraform enabling browserify support for coffee files: sintaxi/terraform#33

cc @brianleroux

@thesmart
Copy link

@thesmart thesmart commented May 15, 2015

Maybe I'm a bit late to the party, but I started writing a partial solution to this issue. One can specify a .man manifest file with the JavaScript and CoffeeScript files and folders they want included. I hope this is useful to others:
sintaxi/terraform@master...thesmart:master

We're using this in production now and it's been great!

@edinabazi
Copy link

@edinabazi edinabazi commented Sep 14, 2016

Has this not been implemented yet?

@temoto
Copy link

@temoto temoto commented Sep 20, 2016

Please do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.