Skip to content

Instantly share code, notes, and snippets.

@popomore
Last active December 20, 2015 07:39
Show Gist options
  • Save popomore/6095159 to your computer and use it in GitHub Desktop.
Save popomore/6095159 to your computer and use it in GitHub Desktop.
Gruntfile 的一些配置

要提前安装

npm install grunt-contrib-watch -g
npm install grunt-contrib-connect -g
npm install connect-livereload -g
module.exports = function(grunt) {
grunt.initConfig({
// https://github.com/gruntjs/grunt-contrib-watch
// grunt.loadNpmTasks('grunt-contrib-watch');
// 页面上插入 <script src="http://localhost:35729/livereload.js"></script>
watch: {
scripts: {
files: ['**/*'],
task: [],
options: {
livereload: true
}
}
}
// https://github.com/gruntjs/grunt-contrib-connect
// grunt.loadNpmTasks('grunt-contrib-connect');
// 通过 connect-livereload 插入 livereload 脚本
connect: {
server: {
options: {
port: 8000,
base: '_site',
middleware: function(connect, options) {
return [
require('connect-livereload')(),
connect.static(options.base),
connect.directory(options.base)
];
}
}
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment