guy mograbi
guy mograbi

Reputation: 28638

Grunt - how can I specify files to multiple targets in the same task?

I have 2 sass targets. one creates debug info, the other does not.

If I don't copy/paste the files section between the targets, it doesn't seem to work.

sass: {
  server: {
    options: {
      debugInfo: true
    },
    files: {
      '.tmp/styles/main.css': '<%= yeoman.app %>/styles/main.scss'
    }
  },
  dist: {

    files: {
      '.tmp/styles/main.css': '<%= yeoman.app %>/styles/main.scss'
    }
  }
},

How can I reuse the files decleration?

Upvotes: 2

Views: 102

Answers (1)

Xavier Priour
Xavier Priour

Reputation: 2121

From a grunt-sass point of view, you can't share the file declaration between multiple targets.

But to avoid duplication in your Gruntfile, you can always use plain old Javascript variables:

var cssFiles = {
  '.tmp/styles/main.css': '<%= yeoman.app %>/styles/main.scss'
}
// ...
grunt.initConfig({
  // ...
  sass: {
    server: {
      options: {debugInfo: true},
      files: cssFiles
    },
    dist: {
      files: cssFiles
    }
  },
  // ...
});

Upvotes: 2

Related Questions