1

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']);


};

Just before my closing body tag I have:

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

Going to https://mysite.dev works without any issues but looking at the Console tab in Chrome 58 I get the error: GET https://mysite.dev:35729/livereload.js net::ERR_CONNECTION_CLOSED. However if go to the url https://mysite.dev:35729/livereload.js I see the code for livereload.js

I use MAMP Pro 4.1.1 to manage my local Wordpress development if that helps. Any help appreciated. Please let me know if I need to provide any other information. Thanks.

hot_barbara
  • 522
  • 1
  • 8
  • 19

1 Answers1

0

After much trial and error I finally got it working:

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']);


};

And just above the closing body tag:

<script src="//mysite.dev:1337/livereload.js"></script>
hot_barbara
  • 522
  • 1
  • 8
  • 19