grunt-copy not re-sending the files from my 'development' folder into 'production', when I modify a file

209 views Asked by At

Looks like it's not re-copying my files when I click save anywhere on my development files (so I want to re-copy onto the Production folder immediately). Here is the part from my Gruntfile.js.

Location of this file: /development/Gruntfile.js

Where I want to copy some files: /production

[...]

copy: {
  watch: {
    options: {
      livereload: true
    },
    files: [
      {expand: true, src: ['css/*'], dest: '../production/', filter: 'isFile'},
      {expand: true, src: ['js/*'], dest: '../production/', filter: 'isFile'},
      {expand: true, src: ['js/vendor/*'], dest: '../production/', filter: 'isFile'},

      {expand: true, src: ['images/**'], dest: '../production/'},
      {expand: true, src: ['public/**'], dest: '../production/'},

      {expand: true, src: ['.htaccess', '404.html', 'apple-touch-icon-precomposed.png', 'crossdomain.xml', 'favicon.ico', 'humans.txt', 'index.html', 'index.php', 'LICENSE.md', 'README.md', 'robots.txt'], dest: '../production/'}
    ]
  }
},

php: {
  watch: {
    options: {
      livereload: true,
      bin: 'C:/php/php.exe',
      ini: 'C:/php/php.ini',
      base: '../production',
      port: 8000
    }
  }
},

watch: {
  options: {
    livereload: true
  },
  site: {
    files: ['*.html', '*.php', 'public/*.html', 'public/*.php'],
    tasks: ['php'],
    options: {
      spawn: false
    }
  }
}

[...]

grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-php');
grunt.loadNpmTasks('grunt-contrib-watch');

grunt.registerTask('default', ['uglify', 'replace', 'stylus', 'cssmin', 'copy:watch', 'php:watch', 'watch']);

I always need to restart the script, to re-send the files into "production" folder.

Thank You for your help!

UPDATE

I made an alter solution: everything happening in development folder, and if I want I can push to the production folder with command line. This way I see the final product in local PHP webserver in the development folder, not production.

grunt.registerTask('default', ['uglify', 'replace', 'stylus', 'cssmin', 'php:watch', 'watch']);
grunt.registerTask('copytoproduction', ['copy']);
0

There are 0 answers