Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

Require JS files similar to require_tree #26

@jekuno

Description

@jekuno

I have already been trying to get a working gulp-rails-pipeline for several days now and am stuck with a beginners question.

Let's say I have two JS models:

# javascripts/models/monkey.js.coffee
class App.Models.Monkey
  constructor: (@name) ->
    # do some setup

and

# javascripts/models/zoo.js.coffee
class App.Models.Zoo
  constructor: () ->
    monkey = new App.Models.Monkey("Charley")
    # ...

If I use Rails Sprockets I can simply add //= require_tree ./models to my application.js. Then I have access to App.Models.Monkey from within App.Models.Zoo out of the box (see example on top). Plain and simple!

Now gulp-rails-pipeline inspired me to ditch the Rails Asset Pipeline.

My question: How can I access my existing JavaScript classes within their namespace so that I can e.g. call new App.Models.Monkey("Charley") from App.Models.Zoo? (see the example on top)

Is there something simliar to require_tree for browserify? Is there something which allows me to simply leave all files as they are, bundle them to one big JS file AND references to e.g. App.Models.Monkey will somehow still magically work?

If not so: Is there some helper which can magically turn all of my classes into RequireJS modules?

Or do I need to turn all of my Models, Controllers, Routers, Views... into RequireJS modules manually (which will result in adding many module.exports and require statements)?

Any help would be highly appreciated. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions