Answer the question
In order to leave comments, you need to log in
How to preserve the order of js files when concatenating with gulp?
Hello! I have the following working order of scripts:
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/socket.io.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="js/angular/angular-route.min.js"></script>
<script src="js/angular/angular-resource.min.js"></script>
<script src="app.js"></script>
<script src="factory/ng-socket-io.js"></script>
<script src="controllers/MainController.js"></script>
<script src="controllers/AuthController.js"></script>
var assets = {
js : [
'public/js/vendor/*.js',
'public/js/angular/*.js',
'public/js/app.js',
'public/factory/*.js',
'public/controllers/*.js'
]
};
gulp.task('js', function(){
gulp.src(assets.js)
.pipe(concat('build.js'))
.pipe(uglify())
.pipe(gulp.dest('public/'))
});
Answer the question
In order to leave comments, you need to log in
To preserve the order, you can use gulp-order .
Minified files can be processed, but if you suddenly want to exclude them from minimization, you can use the gulp-if module . For example
var gulpif = require('gulp-if');
var uglify = require('gulp-uglify');
var notMinified = function (file) {
return !/\.min\.js/.test(file.path);
};
gulp.task('task', function() {
gulp.src('./src/*.js')
.pipe(gulpif(notMinified , uglify()))
.pipe(gulp.dest('./dist/'));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question