【问题标题】:Autoprefixer: Not adding prefixes自动前缀:不添加前缀
【发布时间】:2015-04-27 16:00:07
【问题描述】:

尝试让 autoprefixer 与 Grunt、Livereload 和 node-sass 一起使用。

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

下面是我的 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']);
};

我确实看到我的 grunt 命令的输出说明了一个文件得到了前缀,但是当我打开 css/styles.css 时我没有看到前缀。

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

有什么想法吗?

【问题讨论】:

    标签: css sass grunt-contrib-watch libsass


    【解决方案1】:

    顺序很重要...

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

    应该是:

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

    周一快乐 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-25
      • 2018-05-20
      • 1970-01-01
      • 2020-06-15
      • 2022-11-17
      • 2014-09-29
      • 1970-01-01
      相关资源
      最近更新 更多