grunt server can't be connected

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

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

};

C:\\P         


        
4条回答
  •  被撕碎了的回忆
    2021-02-07 15:25

    By default Grunt starts up the server just for testing (or any other task asked..) and as soon as it's done it exits....

    But fortunately I found a solution which by adding this to your grunt.js file will let you (optionally) halt the server from exiting.

    grunt.registerTask('wait', 'Wait for a set amount of time.', function(delay) {
       var d = delay ? delay + ' second' + (delay === '1' ? '' : 's') : 'forever';
       grunt.log.write('Waiting ' + d + '...');
       // Make this task asynchronous. Grunt will not continue processing
       // subsequent tasks until done() is called.
       var done = this.async();
      // If a delay was specified, call done() after that many seconds.
       if (delay) { setTimeout(done, delay * 1000); }
    });
    

    Then in your command line call it: grunt server wait then you should be able to see it in the browser..

    Make sure you add it inside module.exports = function(grunt){...}

提交回复
热议问题