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, , . - .
, , , , . , - .
!