r.js 前端项目打包

   目录结构

 

原main.js

// RequireJS配置
requirejs.config({
    baseUrl: '../js',//js文件载入基路径
    //enforceDefine: true,//enforceDefine用来强制模块使用define定义,否则可能会报No define call for ...之类错误
    paths: {
        ctrl: './models',
        libs:"./lib",
        'jquery':"./lib/jquery",
        "backbone":"./lib/backbone",
        'underscore':"./lib/underscore"
    } /*路徑別名*/
});

require(["ctrl/m1","jquery"], function (m1,$) {
     var view=new m1()
    $("html body").html(view.el)

});

 

新建built.js

({
    appDir:'./',
    baseUrl: './',
    dir:'./app-build',
    paths: {
        ctrl: './models',
        libs:"./lib",
        'jquery':"./lib/jquery",
        "backbone":"./lib/backbone",
        'underscore':"./lib/underscore"
    },
    modules:[{
        name:"./lib/main"
    }]
})

 

 

posted @ 2014-01-07 02:24  break_happy  Views(7243)  Comments(0Edit  收藏  举报