Add x.min.css & x.min.script to watch

Ok, didn’t have my coffee before I read your post.

So head over to your Gruntfile.js @ line 132 and add the build tasks:

'less:build', 'autoprefixer:build'

Then jump down to line 139 and add uglify to the js:tasks.

This is my final watch which I verified works:

watch: {
  less: {
    files: [
      'assets/less/*.less',
      'assets/less/**/*.less'
    ],
    tasks: ['less:dev', 'autoprefixer:dev', 'less:build', 'autoprefixer:build']
  },
  js: {
    files: [
      jsFileList,
      '<%= jshint.all %>'
    ],
    tasks: ['jshint', 'concat', 'uglify']
  }

Btw, you can see how WP_ENV works, it’s very simple–either it’s set to development or it defaults. Just check here: https://github.com/roots/roots/blob/master/lib/scripts.php#L22.

I also realized that Grunt’s default behavior is not to generate both minified and unminified assets as I previously stated, so it depends on the parameter you pass to grunt. By default, it’s set to generate only unminified assets:

grunt.registerTask('default', [
  'dev'
]);
3 Likes