【问题标题】:Using autoprefixer in grunt for the first time第一次在 grunt 中使用 autoprefixer
【发布时间】:2015-03-03 16:29:27
【问题描述】:

我安装了当前版本的 npm,一切似乎都还不错:

自动前缀加载得很好:

我在本地项目文件夹中创建了一个文件'Grunfile.js':

我在 Windows 8.1 上运行它

从这里到哪里?我如何告诉 grunt 检查文件?如何从命令行调用该函数?还是我从命令行调用函数?

【问题讨论】:

    标签: gruntjs


    【解决方案1】:

    在您的目录中,您需要有 2 个文件,package.json 和 Gruntfile.js。要创建 package.json 文件,请运行命令 npm init

    接下来,您需要将 grunt-autoprefixer 任务添加到您的 package.json 文件中,您可以通过运行 npm install grunt-autoprefixer --save-dev 来完成此操作。

    然后,在 Gruntfile.js 中,它应该看起来像这样:

    module.exports = function(grunt) {
    
      grunt.initConfig({
        autoprefixer: {
          options: {
            // Task-specific options go here.
          },
          your_target: {
            // Target-specific file lists and/or options go here.
          },
        },
      });
    
      grunt.loadNpmTasks('grunt-autoprefixer');
    
      grunt.registerTask('default', [
        'autoprefixer'
      ]);
    
    };
    

    有关在 autoprefixer 上编辑设置的更多详细信息,请查看文档:https://github.com/nDmitry/grunt-autoprefixer

    要了解有关 Grunt 的更多信息,请查看https://learngrunt.com

    【讨论】:

    • 谢谢,我正忙于另一个项目,需要手动完成自动前缀(没有时间浪费)我会在星期一尝试这个解决方案。
    猜你喜欢
    • 1970-01-01
    • 2016-03-29
    • 1970-01-01
    • 2015-11-19
    • 1970-01-01
    • 2015-10-06
    • 1970-01-01
    • 2014-12-18
    • 1970-01-01
    相关资源
    最近更新 更多