module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
server: {
port: 8888,
base: \'.\'
}
});
};
C:\\P
Don't use grunt to serve your project. Grunt is a build tool. Instead, use npm lifecycle scripts.
server.js
var express = require("express"),
app = express();
app.use('/', express.static(__dirname));
app.listen(8888);
package.json
{
"name": "my-project",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "3"
}
}
Now you can run npm start
and life will be great. Grunt is a build tool, not a server. npm is a package lifecycle manager, not a build tool. Express is a server library. Use each in its right place.
The exception to this rule is when you're needing to serve your project to other testing tools in your build stack. The grunt-contrib-connect
plugin is designed specifically with this use case in mind, and has a keepalive
configuration setting that will leave grunt open while serving your static files. This is usually used in conjunction with a watch
task that runs a test suite when either the tests or the code changes.