Answer the question
In order to leave comments, you need to log in
How to organize files in grunt-contrib-concat?
Hello, I am using grunt-contrib-concat for grunt. The problem is that he connects the files not in order, but as he wants. I need jquery.js to be first. Listed the library manually, but it does not help. I'm using the latest version of grunt and grunt-contrib-concat.
Gruntfile.js
module.exports = function (grunt) {
grunt.initConfig({
clean: {
folder: ['build/']
},
bower: {
dev: {
dest: 'public/',
js_dest: 'public/js/lib',
css_dest: 'public/css/lib',
fonts_dest: 'public/fonts/',
images_dest: 'public/img/'
}
},
concat: {
js: {
src: ['public/js/**'],
dest: 'public/js/chill.js'
},
css: {
src: ['public/css/**'],
dest: 'public/css/chill.css'
}
},
autoprefixer: {
options: {
browsers: ['last 2 versions', 'ie 8', 'ie 9', '> 1%']
},
main: {
expand: true,
flatten: true,
src: 'public/css/chill.css',
dest: 'public/css/'
}
},
uglify: {
dist: {
src: ['<%= concat.js.dest %>'],
dest: 'build/js/chill.min.js'
}
},
cssmin: {
options: {
keepSpecialComments: 0
},
dist: {
src: ['<%= concat.css.dest %>'],
dest: 'build/css/chill.min.css'
}
},
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'public/img',
src: ['**/*.{png,jpg,gif}'],
dest: 'build/img',
}]
}
},
copy: {
main: {
expand: true,
cwd: 'public/',
src: ['fonts/*'],
dest: 'build/'
}
},
clean: {
css: ['<%= concat.css.dest %>'],
js: ['<%= concat.js.dest %>']
}
});
grunt.loadNpmTasks('grunt-bower');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('default', ['bower', 'concat', 'autoprefixer', 'uglify', 'cssmin', 'imagemin', 'copy', 'clean']);
};
Answer the question
In order to leave comments, you need to log in
In fact, you really need to enumerate manually. The stack indicates the old version of the syntax. Here's an example from the documentation:
concat: {
bar: {
src: ['src/bb.js', 'src/bbb.js'],
dest: 'dest/b.js',
}
}
options: {
compress: {
hoist_funs: false
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question