Gruntfile:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass: {
      dist: {
        files: {
          'build/css/build.css' : 'sass/main.scss',
        },
      },
    },
    concat: {
      options: {
        separator: ';',
      },
      dist: {
        src: ['js/jquery-getquerystring.min.js','node_modules/featherlight/release/featherlight.min.js', 'js/main.js'],
        dest: 'build/js/build.js',
      },
    },
    concat_css: {
      all: {
        src: ['node_modules/featherlight/release/featherlight.min.css', 'build/css/build.css'],
        dest: 'build/css/build.css',
      }
    },
    watch: {
      sass: {
        files: ['sass/**/*.scss'],
        tasks: ['sass', 'concat_css'],
        options: {
          livereload : 35729,
        }
      },
      js: {
        files: ['js/**/*.js'],
        tasks: ['concat'],
        options: {
          livereload : 35729,
        }
      },
      php: {
        files: ['**/*.php'],
        options: {
          livereload : 35729,
        }
      },
      options: {
        style: 'expanded',
        compass: true,
        livereload : {
          port: '37925',
          host: 'mysite.dev',
          key: grunt.file.read('/absolute/path/to/mysite.key'),
          cert: grunt.file.read('/absolute/path/to/mysite.crt'),
        },
      },
    },
  });


  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-concat-css');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['sass', 'concat', 'concat_css', 'watch']);


};


在我的身体贴标签之前,我有:

<script src="https://mysite.dev:35729/livereload.js"></script>


转到https://mysite.dev可以正常工作,但是在Chrome 58中查看“控制台”选项卡时出现错误:GET https://mysite.dev:35729/livereload.js net::ERR_CONNECTION_CLOSED。但是,如果转到url https://mysite.dev:35729/livereload.js,我会看到livereload.js的代码

如果有帮助,我可以使用MAMP Pro 4.1.1来管理本地Wordpress开发。任何帮助表示赞赏。如果需要提供其他信息,请告诉我。谢谢。

最佳答案

经过多次试验和错误,我终于使它工作了:

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    sass: {
      dist: {
        files: {
          'build/css/build.css' : 'sass/main.scss',
        },
      },
    },
    concat: {
      options: {
        separator: ';',
      },
      dist: {
        src: ['js/jquery-getquerystring.min.js','node_modules/featherlight/release/featherlight.min.js', 'js/main.js'],
        dest: 'build/js/build.js',
      },
    },
    concat_css: {
      all: {
        src: ['node_modules/featherlight/release/featherlight.min.css', 'build/css/build.css'],
        dest: 'build/css/build.css',
      }
    },
    watch: {
      sass: {
        files: ['sass/**/*.scss'],
        tasks: ['sass', 'concat_css']
      },
      js: {
        files: ['js/**/*.js'],
        tasks: ['concat']
      },
      php: {
        files: ['**/*.php']
      },
      options: {
        style: 'expanded',
        livereload : {
          port: 1337,
          host: 'mysite.dev',
          key: grunt.file.read('/absolute/path/to/mysite.key'),
          cert: grunt.file.read('/absolute/path/to/mysite.crt'),
        },
      },
    },
  });


  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-concat-css');
  grunt.loadNpmTasks('grunt-contrib-watch');

  grunt.registerTask('default', ['sass', 'concat', 'concat_css', 'watch']);


};


并在结束标签上方:

<script src="//mysite.dev:1337/livereload.js"></script>

关于wordpress - 在MAMP Pro虚拟主机上进行轮流监视livereload,并且ssl返回错误net::ERR_CONNECTION_CLOSED,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44338154/

10-13 08:59