Reputation: 218
So I'm starting to use Gulp to automate my workflow,I was playing around with it but I ran into that when execute the task to concatenate and uglify multiple files some code that is inside in a IIFE is missing. To concatenate use gulp-usref
.
// a-file.js
(function() {
'use strict';
console.log('a-file');
var variableA = 'variable a';
})();
// anotherfile.js
(function() {
'use strict';
console.log('another-file');
var variableB = 'variable b';
var myFunction = function() {
return 'return function value';
};
})();
// main.js
(function() {
'use strict';
console.log('Hello main');
var variableC = 'variable c';
})();
// gulpfile.js
gulp.task('useref', function() {
return gulp.src('app/*.jade')
.pipe(jade({pretty: true}))
.pipe(useref())
.pipe(gulpIf('*.js', uglify()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(gulp.dest('dist'))
})
When I run the task the file is concatenated and uglified but variableA, variableB, variableC and myFunction
don't appear, just the console.log's.
!function(){"use strict";console.log("a-file")}(),function(){"use strict";console.log("another-file")}(),function(){"use strict";console.log("Hello main")}();
I'm missing a step? or how I can solve this?
Upvotes: 0
Views: 716