Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

require.js question, may be issue #20

Open
wonderwhy-er opened this issue Oct 31, 2013 · 1 comment
Open

require.js question, may be issue #20

wonderwhy-er opened this issue Oct 31, 2013 · 1 comment

Comments

@wonderwhy-er
Copy link

Hi.
Am new to angular and stuff.
Found this thing in search for a way to compile angular app for production in to a single file.
Hoped to use require.js optimize http://requirejs.org/docs/optimization.html

From first try it did not work that well. I did install bower and dependencies trough it.
Then installed require.js globally.
Then created build.js file for optimizer

({
    baseUrl: "app/js/",
    paths: {
        angular: '../../bower_components/angular/angular',
        angularRoute: '../../bower_components/angular-route/angular-route',
        angularMocks: '../../bower_components/angular-mocks/angular-mocks',
        text: '../../bower_components/requirejs-text/text'
    },
    name: "main",
    out: "main.min.js",
    optimize: "none"
})

And changed require.js data-main to point to it.

From first look in to the file it seems to be fine, found dependencies and compiled everything together but it does not work.
For example that's how it defined angular dependency.

define("angular", function(){});

As a result in

define('services',['angular'], function (angular) {


    angular.module('myApp.services', [])
        .value('version', '0.1');
});

angular is undefined.

Can may be someone point me to what I am doing wrong or if there is better way to have nicely separated angular.js files compiled for production?

@ktiedt
Copy link

ktiedt commented Apr 15, 2014

I realize this is 6mo old but... just wanted to state for posterity sake that since Angular does not follow any standard module definitions, you have to use RequireJS Shims to use Angular as describe in the configuration for this project... Just have to look at https://github.com/tnajdek/angular-requirejs-seed/blob/master/app/js/main.js for the example config.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants