更新 Grunt 模板使用的变量
Update variable used by Grunt Template
我正在使用 Grunt 模板,但想知道如何更新使用的变量。请查看下面的示例。
(function () {
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
directory: 'deploy', // I want to be able to update this
concat: {
options: {
separator: ';\n\n',
banner: '/*! Last edited: <%= grunt.template.today("yyyy-mm-dd") %> */\n /* DO NOT EDIT THIS FILE DIRECTLY */\n\n'
},
js_site: {
src: '<%= directory %>/assets/js/src/*.js',
dest: '<%= directory %>/assets/js/site.js',
},
js_vendor: {
src: '<%= directory %>/assets/js/vendor/*.js',
dest: '<%= directory %>/assets/js/vendor.js',
}
},
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('watch', function() {
var args = process.argv;
var dir = args[args.indexOf('--dir') + 1];
// Now update the directory variable above
});
};
})();
这应该有效:
(function () {
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
directory: 'deploy', // I want to be able to update this
concat: {
options: {
separator: ';\n\n',
banner: '/*! Last edited: <%= grunt.template.today("yyyy-mm-dd") %> */\n /* DO NOT EDIT THIS FILE DIRECTLY */\n\n'
},
js_site: {
src: '<%= directory %>/assets/js/src/*.js',
dest: '<%= directory %>/assets/js/site.js',
},
js_vendor: {
src: '<%= directory %>/assets/js/vendor/*.js',
dest: '<%= directory %>/assets/js/vendor.js',
}
},
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('watch', function() {
var args = process.argv;
var dir = args[args.indexOf('--dir') + 1];
// Now update the directory variable above
grunt.config.set('directory', dir);
});
};
})();
我正在使用 Grunt 模板,但想知道如何更新使用的变量。请查看下面的示例。
(function () {
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
directory: 'deploy', // I want to be able to update this
concat: {
options: {
separator: ';\n\n',
banner: '/*! Last edited: <%= grunt.template.today("yyyy-mm-dd") %> */\n /* DO NOT EDIT THIS FILE DIRECTLY */\n\n'
},
js_site: {
src: '<%= directory %>/assets/js/src/*.js',
dest: '<%= directory %>/assets/js/site.js',
},
js_vendor: {
src: '<%= directory %>/assets/js/vendor/*.js',
dest: '<%= directory %>/assets/js/vendor.js',
}
},
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('watch', function() {
var args = process.argv;
var dir = args[args.indexOf('--dir') + 1];
// Now update the directory variable above
});
};
})();
这应该有效:
(function () {
"use strict";
module.exports = function(grunt) {
grunt.initConfig({
directory: 'deploy', // I want to be able to update this
concat: {
options: {
separator: ';\n\n',
banner: '/*! Last edited: <%= grunt.template.today("yyyy-mm-dd") %> */\n /* DO NOT EDIT THIS FILE DIRECTLY */\n\n'
},
js_site: {
src: '<%= directory %>/assets/js/src/*.js',
dest: '<%= directory %>/assets/js/site.js',
},
js_vendor: {
src: '<%= directory %>/assets/js/vendor/*.js',
dest: '<%= directory %>/assets/js/vendor.js',
}
},
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('watch', function() {
var args = process.argv;
var dir = args[args.indexOf('--dir') + 1];
// Now update the directory variable above
grunt.config.set('directory', dir);
});
};
})();