在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):welldone-software/gulp-durandal开源软件地址(OpenSource Url):https://github.com/welldone-software/gulp-durandal开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):
gulp-durandal
Also see the [Gulp Plugin docs] (http://durandaljs.com/documentation/Gulp.html) on the official Durandal site. Getting StartedThis plugin requires Gulp If you haven't used Gulp before, be sure to check out the Getting Started guide, as it explains how to create a Gulpfile as well as install and use Gulp plugins. Once you're familiar with that process, you may install this plugin with this command: npm install gulp-durandal --save-dev Once the plugin has been installed, it should be required inside your Gulpfile: var durandal = require('gulp-durandal'); The "durandal" streamThis plugin compiles all the scripts and views of a Durandal project into a single js file. The task expects that the Durandal files are under a single app dir (usually named app) and that there is a single main module (usually at app/main.js) that contains both the requirejs path configuration and the initial module that executes.
OverviewIn your project's Gulpfile, lunch the plugin inside a task with the wanted configurations. The plugin will return the stream of the wanted file and it's source map. var durandal = require('gulp-durandal');
gulp.task('durandal', function(){
return durandal({
baseDir: 'app', //Same as default, so not really required.
main: 'main.js', //Same as default, so not really required.
output: 'main.js', //Same as default, so not really required.
//WARNING: Change filename if output and input dirs are the same to avoid input overwrites.
almond: true,
minify: true
})
.pipe(gulp.dest('dir/to/save/the/output'));
}); For async tasks, handling of gulp.task('durandal-async', function(cb){
durandal({
...
})
.on('error', function(err) {
console.error('error. ' + err);
})
.pipe(gulp.dest('dir/to/save/the/output'))
.on('end', cb); Optionsoptions.verboseType: Should the task emit information about as it progresses. options.baseDirType: The path, relative to the gulp cwd, to the root directory of your durandal app (usually called This directory is expected to contain all your views, viewmodels, service modules etc. All files under it are are automatically included in the output: *.js files as modules and text files (*.html, *.json) as 'text!' prefixed modules. options.mainType: The path to the main js file of the application, relative to the baseDir, or This is where we expect to find the project's This file also contains the main module of the application.
options.outputType: Output js file's name.
options.minifiyType: Determines whether the output file is minified (using Uglify2). options.almondType: True to wrap the generated code and include a Durandal specific version of AlmondJS, to replace the need for the much bigger requiresjs, and create a single and self sufficient output file. (Read more about AlmondJS and the Durandal version) If the value is a string, it should be the path to an almond script, relative to the gulp cwd. The result is similar to setting the value to options.extraModulesType: A list of extra modules to include in the output file, e.g. We will automatically include any module whose file is under the baseDir, as well as any of their explicit dependencies. Alas, non-explicit dependencies are not recognized automatically by r.js. If their files are outside the baseDir, they will not be recognized by our scanning process. Examples are the Durandal transitions that are loaded dynamically by convention, and Durandal plugins are loaded via In short, all required modules must either reside under the baseDir, be an explicit dependency of a module under that dir, or be explicitly included via the extraModules option. Module names are resolved and mapped to files according to the paths and mapping in the options.durandalDynamicModulesType: True to add default Durandal dynamic modules to options.requireType: Determines if a ' When The tasks avoids inserting the call if the value is set to false. If it true, it will insert the options.moduleFilterType: After all top level modules are resolved, they are passed via a filter function, so that you have a chance to exclude any modules for any reason you might have. For example, if you would not like to include the views, you could supply the following function: function(moduleName){
return moduleName.indexOf('text!') == -1;
} options.rjsConfigAdapterType: An advanced argument that allows complete control over the parameters passed to the rjs optimizer. You can add new fields, remove and change any parameter calculated and defined by the plugin, just before the config object is passed to the optimizer. The 'gulp-durandal' plugin tries to hide the complexity of If this is the case, then the function(rjsConfig){
rjsConfig.pragmas = {
fooExclude: true
};
return rjsConfig;
} Usage ExamplesThe ContributingIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp. Release History
License |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论