From: gustavo Date: Sun, 22 May 2016 20:10:50 +0000 (+0200) Subject: gulp-my-tasks: inject workers X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=c4915125540ef5f7ab7c3864c09462db96170a8d;p=JavaScriptForFun gulp-my-tasks: inject workers --- diff --git a/gulp/gulp-my-tasks/package.json b/gulp/gulp-my-tasks/package.json index 0640701..72be9fa 100644 --- a/gulp/gulp-my-tasks/package.json +++ b/gulp/gulp-my-tasks/package.json @@ -19,6 +19,7 @@ "gulp-angular-templatecache": "~1.8.0", "gulp-batch": "~1.0.5", "gulp-bytediff": "~1.0.0", + "gulp-content-to-variable": "~0.1.0", "gulp-cssnano": "~2.1.2", "gulp-filter": "~4.0.0", "gulp-header": "~1.8.2", @@ -35,6 +36,7 @@ "gulp-nodemon": "~2.0.7", "gulp-order": "~1.1.1", "gulp-print": "~2.0.1", + "gulp-rename": "~1.2.2", "gulp-rev": "~7.0.0", "gulp-rev-replace": "~0.4.3", "gulp-task-listing": "~1.0.1", diff --git a/gulp/gulp-my-tasks/tasks/tasks.config.js b/gulp/gulp-my-tasks/tasks/tasks.config.js index 317a975..52e7242 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.config.js +++ b/gulp/gulp-my-tasks/tasks/tasks.config.js @@ -25,6 +25,9 @@ module.exports = function() { jsFilesStubs: [ main + 'stubs/**/*.js' ], + jsFilesWorkers: [ + main + 'workers/**/*.js' + ], index: main + 'index.html', jsHintConfigurationFile: $.path.join(__dirname, '.jshintrc'), jscsConfigurationFile: $.path.join(__dirname, '.jscsrc'), @@ -38,6 +41,7 @@ module.exports = function() { html: app + '**/*.html', templateFile: 'templates.js', + workersFile: 'workers.js', temp: './.tmp/', diff --git a/gulp/gulp-my-tasks/tasks/tasks.js b/gulp/gulp-my-tasks/tasks/tasks.js index be78912..c55d5d2 100644 --- a/gulp/gulp-my-tasks/tasks/tasks.js +++ b/gulp/gulp-my-tasks/tasks/tasks.js @@ -188,7 +188,7 @@ module.exports = function(gulp, customConfig) { * * @returns {stream} The stream. */ - gulp.task('build', ['wireup', 'templatecache'], function() { + gulp.task('build', ['wireup', 'templatecache', 'workers'], function() { log('*** Building application for production - Optimizing assets - HTML,CSS,JS ***'); @@ -198,12 +198,16 @@ module.exports = function(gulp, customConfig) { var jsAppFilter = plugins.filter('**/app.min.js', {restore: true}); var jslibFilter = plugins.filter('**/lib.min.js', {restore: true}); var templateCache = config.temp + config.templateFile; + var workersFile = config.temp + config.workersFile; return gulp.src(config.index) // Inject templates .pipe(inject(templateCache, 'templates')) + // Inject workers + .pipe(inject(workersFile, 'workers')) + // Gather all assets from the html with useref .pipe(assets) @@ -371,6 +375,29 @@ module.exports = function(gulp, customConfig) { * @ngdoc function * * @description + * Inline workers and shared workers + * + * @returns {stream} + */ + gulp.task('workers', function() { + + log('*** Inline workers or shared workers ***'); + + return gulp + .src(config.jsFilesWorkers) + .pipe(plugins.contentToVariable({ + variableName: 'workers', + asMap: true + })) + .pipe(plugins.rename(config.workersFile)) + .pipe(gulp.dest(config.temp));; + + }); + + /** + * @ngdoc function + * + * @description * Inject files in a sorted sequence at a specified inject label. * * @param {Array|string} source Source files (glob patterns)