From 6a2ab3bdaa6b290f8d1b3439dbd47b8cdc156db9 Mon Sep 17 00:00:00 2001 From: xenogenesi Date: Fri, 29 Apr 2016 14:41:08 +0200 Subject: [PATCH] add a bundles test --- Gruntfile.js | 11 +++++++-- app/main.js | 10 +++++--- app/viewmodels/shell.js | 3 ++- index2.html | 44 ++++++++++++++++++++++++++++++++++ lib/test-bundle/test-bundle.js | 15 ++++++++++++ 5 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 index2.html create mode 100644 lib/test-bundle/test-bundle.js diff --git a/Gruntfile.js b/Gruntfile.js index caa727c..5d7cfa6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,12 +15,18 @@ module.exports = function( grunt ) { baseUrl: 'app/', paths: { 'jquery': '../lib/jquery/jquery-1.12.3', - 'knockout': '../lib/knockout/knockout-3.4.0.debug', + 'knockout': '../lib/knockout/knockout-3.4.0', 'text': '../lib/require/text', 'durandal': '../lib/durandal/js', 'plugins': '../lib/durandal/js/plugins', 'transitions': '../lib/durandal/js/transitions', 'bootstrap': '../lib/bootstrap/js/bootstrap', + 'mymodules': 'empty:', + 'mymodule1': 'empty:', + 'mymodule2': 'empty:' + }, + bundles: { + 'mymodules': ['mymodule1', 'mymodule2'] } }; @@ -53,7 +59,7 @@ module.exports = function( grunt ) { dest: 'build/' }, index: { - src: 'index.html', + src: ['index.html', 'index2.html'], dest: 'build/' }, css: { @@ -159,5 +165,6 @@ module.exports = function( grunt ) { grunt.registerTask('default', ['jshint', 'jasmine:dev', 'connect:dev:livereload', 'open:dev', 'watch:dev']); grunt.registerTask('build', ['jshint', 'jasmine:dev', 'clean', 'copy', 'durandal:main', 'uglify', 'jasmine:build', 'connect:build', 'open:build', 'watch:build']); + grunt.registerTask('build-only', ['jshint', 'clean', 'copy', 'durandal:main', 'uglify']); }; diff --git a/app/main.js b/app/main.js index 1662a04..301acfa 100644 --- a/app/main.js +++ b/app/main.js @@ -7,7 +7,11 @@ 'transitions' : '../lib/durandal/js/transitions', 'knockout': '../lib/knockout/knockout-3.4.0', 'bootstrap': '../lib/bootstrap/js/bootstrap', - 'jquery': '../lib/jquery/jquery-1.12.3' + 'jquery': '../lib/jquery/jquery-1.12.3', + 'mymodules': '../lib/test-bundle/test-bundle' + }, + bundles: { + 'mymodules': ['mymodule1', 'mymodule2'] }, shim: { 'bootstrap': { @@ -18,9 +22,9 @@ }); define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'bootstrap'], function (system, app, viewLocator) { - //>>excludeStart("build", true); + // > > excludeStart("build", true); system.debug(true); - //>>excludeEnd("build"); + // > > excludeEnd("build"); app.title = 'Durandal Starter Kit'; diff --git a/app/viewmodels/shell.js b/app/viewmodels/shell.js index cb09665..f79998e 100644 --- a/app/viewmodels/shell.js +++ b/app/viewmodels/shell.js @@ -1,4 +1,5 @@ -define(['plugins/router', 'durandal/app'], function (router, app) { +define(['plugins/router', 'durandal/app', 'mymodule1', 'mymodule2'], function (router, app, mymodule1, mymodule2) { + console.log('modules test:', mymodule1.test, mymodule2.test); return { router: router, search: function() { diff --git a/index2.html b/index2.html new file mode 100644 index 0000000..07db7c1 --- /dev/null +++ b/index2.html @@ -0,0 +1,44 @@ + + + + Durandal + + + + + + + + + + + + + + + + + + + + + +
+
+
+ Durandal Starter Kit +
+ +
+
+ + + + \ No newline at end of file diff --git a/lib/test-bundle/test-bundle.js b/lib/test-bundle/test-bundle.js new file mode 100644 index 0000000..48f5047 --- /dev/null +++ b/lib/test-bundle/test-bundle.js @@ -0,0 +1,15 @@ +console.log("defining modules..."); + +define('mymodule1', ['jquery'], function($) { + console.log('within mymodule1', $.fn.jquery); + return { + test: 'module1' + }; +}); + +define('mymodule2', ['jquery'], function($) { + console.log('within mymodule2', $.fn.jquery); + return { + test: 'module2' + }; +});