且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Yeoman中配置grunt-contrib-sass

更新时间:2022-10-31 15:57:32

我认为存在一个问题:

  dest:'<%= yeoman.app%> / styles / css' ,

并且应该有效。

As I want to use Bourbon, I'm looking forward to remove compass grunt task and use plain sass task, however for some reason it doesn't seems to compile my scss files.

I have the following directory structure:

yeomanApp/
  app/
    styles/
      css/
      scss/

My Gruntfile.js looks something like this:

...
grunt.initConfig({
  ...
  sass: {
    dist: {
      files: [{
        expand: true,
        cwd: '<%= yeoman.app %>/styles',
        src: ['scss/{,*/}*.scss'],
        dest: 'css',
        ext: '.css'
      }]
    }
  },
  ...
});

grunt.loadNpmTasks('grunt-contrib-sass');

grunt.registerTask('server', function (target) {
  if (target === 'dist') {
    return grunt.task.run(['build', 'connect:dist:keepalive']);
  }

  grunt.task.run([
    'clean:server',
    'concurrent:server',
    'sass',
    'autoprefixer',
    'connect:livereload',
    'watch',
  ]);
});
...

When running this task:

$ grunt sass
Running "sass:dist" (sass) task

Done, without errors.

However, my scss files are not compiled into app/styles/css.

What am I missing?

I think there's a problem:

dest: '<%= yeoman.app %>/styles/css',

and should work.