grunt server can't be connected

后端 未结 4 2089
借酒劲吻你
借酒劲吻你 2021-02-07 14:50
module.exports = function(grunt) {

  // Project configuration.
    grunt.initConfig({
      server: {
        port: 8888,
        base: \'.\'
      }
    });

};

C:\\P         


        
4条回答
  •  后悔当初
    2021-02-07 15:39

    The server task only runs as long as it is needed, but you can keep it from quitting. From a comment by widget on another question: In your grunt.js file define a task named run that runs the tasks server and watch.

    grunt.registerTask("run", "server watch");
    

    The watch task runs indefinitely, so it prevents the server task from ending. Just make sure you also have a config for the watch task. Here it is all together in your grunt.js file:

    module.exports = function (grunt) {
      // …
      grunt.initConfig({
        // …
        watch: {
          files: "",
          tasks: "lint qunit",
        },
        // …
      });
    
      grunt.registerTask("run", "server watch");
    };
    

    From the command line just type:

    $ grunt run
    

    The server will stay up and running.

    Alternatively, as @NateBarr points out, from the command line you can run:

    $ grunt server watch
    

提交回复
热议问题