我是grunt 的新手,我想使用grunt將java腳本文件連接到一個文件 並且我有6個js文件,但它們需要以某種順序運行代碼像jQuery的錯誤應加載第一 但來自咕嚕結果文件不保留該序列 我試了很多事情,如安排他們在SRC或使多個文件夾,但沒有奏效使用grunt按順序排列文件
注 - 當我通過複製和粘貼在一個文件中手動連接它工作正常 所以是否有任何命令讓grunt連接這個文件在我寫在src中的這個文件中作爲例子 這是我gruntfile.js太
module.exports = function(grunt) {
// 1. All configuration goes here
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// 1 - this is contecnate js files call them in one file only
concat: {
options: {
separator: ';',
},
dist: {
src: ['src/public/js/jquery.min.js','src/public/js/bootstrap.js','public/js/modernizr.custom.77555.js',
'public/js/jquery.magnific-popup.js',
'public/js/jquery.mixitup.min.js','public/js/popup-box.js' ],
dest: 'dist/1newbuilt.js',
},
},
uglify: {
build: {
src: 'dist/1newbuilt.js',
dest: 'dist/1newbuilt.min.js'
}
}
});
// end 1 - this is contecnate js files call them in one file only
// 3. Where we tell Grunt we plan to use this plug-in.
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
// 4. Where we tell Grunt what to do when we type "grunt" into the terminal.
grunt.registerTask('default', ['concat', 'uglify']);
};
我需要的文件在一些訂單要連接像第一添加1.js再加入2.js後 所以我寫序列中的文件,但這樣沒也沒用 -
感謝您的評論和代碼段 審查後,我發現有一個錯誤,當我調用兩個文件中的Java腳本文件開始於src/pu ..這是不必要的,之後寫入正確的src所以我沒有發現結果文件沒有完成@thebringking – ramyMorad 2014-12-13 02:53:13