Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9266815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:24:15+00:00 2026-06-18T14:24:15+00:00

I have a project written in CoffeeScript that uses AngularJS. My vendor dependancies are

  • 0

I have a project written in CoffeeScript that uses AngularJS. My vendor dependancies are installed using Bower and my file structure is like this:

- assets
 - js
  - app
   - model
    - *.coffee
   - factory
    - *.coffee
   ...
   - app.coffee
   - config.coffee
   - routes.cofeee
  - vendor
   - angular
   - lodash
   ...
  - dist

What I’m trying to do is the following:

  1. I’m trying to work out how I can use RequireJS’s r.js to optimise my app files so that I essentially get a concatenated file all ordered nice (so vendor dependancies, my config and routes, and they my app files).
  2. Integrate this into my Grunt file.

I’ve tried using the r.js optimiser but maybe I’ve being too silly as all it seems to do is copy my app files (minus the vendor dependancies) into the dist folder; it does, however, manage to optimise the coffee generated js files.

Has anyone got any experience with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:24:17+00:00Added an answer on June 18, 2026 at 2:24 pm

    I figured it out: r.js works by reading your mainConfigFile and any modules you name within your configuration, the important note here is that r.js only looks at the first require/define within your named modules and goes off to seek them; so, for example, I had one named module called app:

    require ['config'], (cfg) ->
      require ['angular'], (A) ->
        A.module cfg.ngApp, []
    
        require ['routes'], () ->
          require [
            'factory/a-factory',
    
            'service/a-service',
    
            'controller/a-controller'
          ], () ->
            A.bootstrap document, [cfg.ngApp]
    

    The problem here was that r.js never got past the first require statement and thus the concatenation wasn’t working. When I changed this to, say (my app.coffee):

    require ['config'], (cfg) ->
      require ['angular'], (A) ->
        A.module cfg.ngApp, []
    
        require ['bootstrap'], (bootstrap) ->
          bootstrap()
    

    And my bootstrap.coffee:

    define [
      'config',
      'angular',
      'routes',
    
      'factory/a-factory',
    
      'service/a-service',
    
      'controller/a-controller'
    ], (cfg, A, routes) ->
      class Bootstrap
        constructor: () ->
          routes()
    
          A.bootstrap document, [cfg.ngApp]
    

    This meant that I only needed to define angular and bootstrap in my r.js configuration as includes and then r.js would do the rest, like so:

    baseUrl: 'assets/js/app',
    mainConfigFile: 'assets/js/app/config.js',
    name: 'app',
    include: [
      '../vendor/requirejs/require',
      'bootstrap'
    ],
    out: 'assets/js/dist/app.js'
    

    And now it all works fine! ~~It’s a shame that I have to tell r.js to include requirejs though, maybe I’ve done something silly there?~~

    Blimey, I’m such a dingus!

    So in my HTML I was loading my concatenated script as:

    <script src="assets/js/dist/app.js"></script>
    

    When really it should be loaded like this:

    <script src="assets/js/vendor/requirejs/require.js" data-main="assets/js/dist/app"></script>
    

    D’oh!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a project written in VB.NET using Visual Studio 2008 that is to
I would like to ask that if I have a project written in C
I have a project that was written using ACtionScript 3 in the Flash Builder
I'm writing unit tests for a project (written in PHP, using PHPUnit) that have
We have an old project written using Managed C++ syntax. I would like to
I have a project written in C and I would like to know if
I have a project that has a GUI (written in QT) and a command-line
we have a project written in Delphi that we want to convert to C#.
I have an old personal project written in Java 1.4 that I am porting
I have an ASP.NET 3.5 webforms project written in VB that involves a multi-table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.