这个grunt配置 是个人一个程序员朋友从网上无心间看到的,而后他亲测了下,恩,是能够的。不过我到目前还未测试过是否能够。php
1、安装node, 首先确保电脑已有node的环境。
而后 运行 npm install -g grunt-cli
而后运行 grunt --version 查看当前grunt是否安装;
2、在项目根目录下面建立一个js文件,叫gruntfile.js;
配置项以下:
module.exports = function (grunt) {
var config = {
sftp: {
'dongsheng.csgrid.cn': { //项目名称
files: {
'./': [
'Lib/**',
'css/**',
'js/**',
'img/**',
'Tpl/**',
'index.php',
'.htaccess'
] //本地须要上建立的文件夹,不须要可在前面加注释
},
options: {
// 测试环境
path:'/backup/apache2/vhosts/dongsheng.csgrid.cn', //服务器端项目地址
host: '118.190.67.87', //服务器id
username: 'root', //服务器用户名
password: 'chArm1nG', //服务器密码
port: 22, //端口
showProgress: true, 一下默认
createDirectories: true,
srcBasePath: './'
}
}
}
};
grunt.initConfig(config);
grunt.loadNpmTasks('grunt-ssh');
grunt.registerTask('uploadtods', ['sftp:dongsheng.csgrid.cn']);//项目名称 对应上面的项目名称
}
3、配置好以后再当前项目下执行以下命令
npm install grunt --save-dev 在本地项目下面安祖行grunt,
而后在执行 npm install grunt-ssh --save-dev
4、 成功以后执行 grunt uploadtods 这个命令, 他就会将你配置里须要提交的目录都提交到服务器。
css