grunt livereload и смотрите с php, без йомена

Больше не могу, много часов пытаюсь, но ничего. проблема идет с LiveReload, у меня не перезагружаются изменения в браузере. Я могу сказать, что если он работает, то скомпилированные js и css, но не livereload.

Я поместил сюда свой файл gruntfile.js, посмотрите, видите ли вы ошибку.

grunt test --verbose

Я провел ряд тестов, и терминал показывает мне следующее, но фактически не выполняет перезагрузку в браузере.

Running "recess:dist" (recess) task
Verifying property recess.dist exists in config...OK
Files: ./css/landing.less -> ./css/landing.css
Options: banner="", compress, footer="", report=null, compile
Writing ./css/landing.css...OK
File "./css/landing.css" created.
Original: 4553 bytes.
Minified: 3687 bytes.

Done, without errors.
Live reloading css/landing.less...
Completed in 4.493s at Fri Jan 03 2014 15:51:37 GMT+0100 (CET) - Waiting...
php: estructura.php has changed
OK
>> File "template.php" changed.

Live reloading template.php...
Completed in 0.001s at Fri Jan 03 2014 15:51:54 GMT+0100 (CET) - Waiting...

grunfile.js

'use strict';
var path = require('path');
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

var gateway = require('gateway');
var phpGateway = function (dir){
    return gateway(require('path').resolve(dir), {
        '.php': 'php-cgi'
    });
};
module.exports = function(grunt) {
grunt.initConfig({
 pkg: grunt.file.readJSON('package.json'),
  miapp: {
        app: '.'
      },
    concat: {
        all: {
          src: "./js/*.js",
          dest: "./js/todos.js"
        },
      },  
      uglify: {
        options:{
             banner: '/* <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
        },
        my_target: {
          files: {
          'js/landing.min.js': ['js/landing.js']
          },

        },

    },
    recess: {
    dist: {
        options: {
            compile: true,
            compress:true
        },
        files: {
            './css/landing.css': ['./css/landing.less']
        },

       },

    },jshint:{

        all:['./js/landing.js']

      },jsonlint: {
      sample: {
        src: [ 'some/valid.json' ]
      },  
},imagemin: {                          // Task
    static: {                          // Target
      options: {                       // Target options
        optimizationLevel: 3
      }
    },
    dynamic: {                         // Another target
      files: [{
        expand: true,                  // Enable dynamic expansion
        cwd: './',                   // Src matches are relative to this path
        src: ['**/images/*.{png,jpg,gif}'],   // Actual patterns to match
        dest: 'test/'                  // Destination path prefix
      }]
    },
  },watch: {
    options: {
          livereload: true
        },
     css:{
        files: ['css/landing.less'],
        tasks: ['recess'],
      },
      js:{
         files: ['js/landing.js'],
         tasks: ['build']
      },
      php:{
         files: ['./**/*.php']

        }, 
     // images:{
      //      options: { livereload: true },
      //      files: [ 'images/**/*.{png,jpg,jpeg,gif,webp,svg}']
       // }

      },php: {
      dev:{
        options: {
          port: 8000,
         // keepalive: true,
          open: true,
          base: '<%= miapp.app %>',
          hostname: 'localhost'
          }
        },
        watch: {
          options: {
            livereload: 45678
          },
        }
      },mocha: {
        all: {
          options: {
            run: true,
            urls: ['http://<%= php.dev.options.hostname %>:<%= php.dev.options.port %>/*.php']
          }
        }
      },
    bower: {
      dev: {
        dest: './components'
      },
    },
    'bower-install': {
      app: {
        src: ['template.php']
      },
    },
  });
grunt.event.on('watch', function(action, filepath, target) {
  grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
});

  // registramos las tareas (plugins) desde npm en Grunt
  //grunt.loadTasks('tasks');

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-recess');
  grunt.loadNpmTasks('grunt-contrib-connect');
  grunt.loadNpmTasks('grunt-jsonlint');
  grunt.loadNpmTasks('grunt-contrib-imagemin');
  grunt.loadNpmTasks('grunt-bower-task');
  grunt.loadNpmTasks('grunt-bower-install');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-php');
  grunt.loadNpmTasks('grunt-mocha');

  //grunt.loadTasks('watch');
    //grunt.registerTask('watch', ['watch']);

  // registramos las tareas que se pueden ejecutar y el orden
  grunt.registerTask("test", ["php","watch"]);
  grunt.registerTask("default", ["uglify","connect","recess","watch" ]);
  grunt.registerTask("build", ["concat", "uglify", "recess"]);
  grunt.registerTask("load", ["connect"]);
  grunt.registerTask("js", ["jshint"]);
  grunt.registerTask("plantilla", ["bower-install"]);
  grunt.registerTask("images", ["imagemin"]);
  //grunt.registerTask('watch', ['watch']);


};

Я надеюсь, что вы можете мне помочь.


person JCC    schedule 03.01.2014    source источник


Ответы (1)


Если вы работаете над MAMP... Возможно, вам нужно посмотреть на эту конфигурацию кеша по умолчанию в php5.5.3 и удалить ее:

Время MAMP между просмотром изменений в реальном времени

А также, возможно, вам также нужно проверить, является ли ваше расширение livereload (https://addons.mozilla.org/en-US/firefox/addon/livereload/ для Firefox) хорошо установлен и включен.

person Erwan Ledoux    schedule 14.01.2014