2015-04-27 77 views
0

试图让autoprefixer与Grunt,Livereload和node-sass一起工作。Autoprefixer:不添加前缀

我似乎没有得到任何前缀。

下面是我的Gruntfile.js:

module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
    autoprefixer: { 
     options: { 
     browsers: ['last 8 versions'], 
     map: true 
     }, 
     dist: { 
     files: { 
      'css/styles.css': 'css/styles.css' 
     } 
     } 
    }, 

    // Sass to CSS 
    sass: { 
     app: { 
     files: [{ 
      expand: true, 
      cwd: 'scss', 
      src: ['*.scss'], 
      dest: 'css', 
      ext: '.css' 
     }] 
     }, 
     options: { 
     sourceMap: true, 
     outputStyle: 'nested', 
     imagePath: "../", 
     } 
    }, 

    watch: { 
     sass: { 
     files: ['scss/{,*/}*.{scss,sass}'], 
     tasks: ['sass'] 
     }, 
     html: { 
     files: ['*.html'] 
     }, 
     options: { 
     livereload: true, 
     spawn: false 
     }, 
     styles: { 
     files: ['css/styles.css'], 
     tasks: ['autoprefixer'] 
     } 
    }, 
    }); 

    // Loads Grunt Tasks 
    grunt.loadNpmTasks('grunt-sass'); 
    grunt.loadNpmTasks('grunt-autoprefixer'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 

    // Default task(s). 
    grunt.registerTask('default', ['autoprefixer','sass', 'watch']); 
}; 

我看到我的呼噜声命令说着有关文件中获取前缀的输出,但是当我打开CSS/Styles.css中我看没有前缀。

$ grunt 
Running "autoprefixer:dist" (autoprefixer) task 
>> 1 autoprefixed stylesheet created. 

任何想法?

回答

0

顺序很重要...

grunt.registerTask('default', ['autoprefixer','sass', 'watch']); 

应该是:

grunt.registerTask('default', ['sass', 'autoprefixer', 'watch']); 

快乐星期一:)