找不到 "autoprefixer" 任务的插件

Plugin for the "autoprefixer" task not found

我是 Angular 2 开发的新手,如果这还不够,我正在尝试与作为后端的 Play 框架集成。

我正在尝试关注 Denis Sinyakov 关于此类设置的精彩 post:https://www.toptal.com/java/building-modern-web-applications-with-angularjs-and-play-framework

想法是将传入 Angular 应用的请求代理到 Play 应用。

它建议将 'autoprefixer' 任务作为我遇到问题的配置的一部分。 当我启动 Angular 应用程序时,出现以下错误:

jit-grunt: Plugin for the "autoprefixer" task not found.

以下是我的 Gruntfile.js 的部分内容,您可能会感兴趣。

// Time how long tasks take. Can help when optimizing build times
  require('time-grunt')(grunt);

  // Automatically load required Grunt tasks
  require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn'
  });

  // Configurable paths for the application
  var appConfig = {
    app: require('./bower.json').appPath || 'app',
    dist: 'dist'
  };

还有这个

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

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

感谢有关如何安装此插件并在必要时进一步配置它的所有提示。

jit-grunt: Plugin for the "autoprefixer" task not found.

这意味着jit-grunt无法找到autoprefixer模块 您可以像这样更新 jit-grunt:

require('jit-grunt')(grunt, {
    useminPrepare: 'grunt-usemin',
    ngtemplates: 'grunt-angular-templates',
    cdnify: 'grunt-google-cdn',
    autoprefixer: 'grunt-autoprefixer', //help jit resolve autoprefixer
  });

最好使用上面的方法,但如果 jit-grunt 仍然有问题,你可以尝试添加:

grunt.loadNpmTasks('grunt-autoprefixer');

下一条错误信息:

**Required config property "autoprefixer.server" missing. **.

出现是因为您在 gruntfile 中缺少 autoprefixer.server 目标,确保它是这样声明的:

 autoprefixer: {
     server:{
        options: {
          // Task-specific options go here.
        },
        your_target: {
          // Target-specific file lists and/or options go here.
        },
     }, 
  },

有关正确的选项和用法,请参阅 https://github.com/nDmitry/grunt-autoprefixer