Durandal optimization with Gulp and Gulp - Durandal does not work

We are creating an application with Durandal, which is currently quite large, and we are currently studying the combination of all the JS files in the App folder into the main-built.js file. Pretty simple and ordinary things that I guess.

I am using Gulp with the extension Gulp -Durandal. Here is our gulpfile:

var gulp = require('gulp');
var durandal = require('gulp-durandal');

gulp.task('build-portal', function () {
    durandal({
        baseDir: 'app',
        main: 'main.js',
        output: 'main-built.js',
        almond: false,
        minify: false
    }).pipe(gulp.dest('app'));
});

And here is a fragment of our main.js file

require.config({
paths: {
    'text': '../Scripts/text',
    'durandal': '../Scripts/durandal',
    'plugins': '../Scripts/durandal/plugins',
    'transitions': '../Scripts/durandal/transitions'
},
shim: {
},
waitSeconds: 0
});

define('jquery', [], function () { return jQuery; });
define('knockout', [], function () { return ko; });
define('ga', function () { return ga; });

define(
    ["require", "exports", "durandal/app", "durandal/viewLocator", "durandal/system", "plugins/router", "services/logger", "modules/knockout.extensions", "modules/knockout.validation.custom"],
    function (require, exports, __app__, __viewLocator__, __system__, __router__, __logger__, __koExtensions__, __koValidationCustom__) {
        var app = __app__;
        var viewLocator = __viewLocator__;
        var system = __system__;
        var router = __router__;

As you can see in the gulpfile, we don’t want to use Almond, but RequireJs instead, for some reason, almonds do not work with our project, and in any case we prefer RequireJs more than the almonds at the end. Where he looks to brake. Running the command to create the main-built.js file took some time, but in the end I get a file built with everything in it.

, , . , .

, , , , . : https://github.com/maroy1986/DurandalGulpBundling

true, , almound, Gulp, RequireJs, , . - .

, , , , . , - .

!

+4
2

. , require.js , Durandal, . , :

gulp.task("durandal", function() {
    return durandal({
        baseDir: "app",
        main: "main.js",
        output: "main-built.js",
        almond: false,
        minify: true,
        rjsConfigAdapter: function(config) {
            //Tell requirejs to load the "main" module
            config.insertRequire = ["main"];
            return config;
        }
    })
    .pipe(gulp.dest("dist"));
});
+1

gulp durandal. :

 TypeError: Cannot read property 'normalize' of undefined

rjs, , gulp ( , minify, output...):

rjsConfigAdapter : function(rjsConfig){
            rjsConfig.deps = ['text'];
            return rjsConfig;
        }

, , minify, , .

+1

All Articles