2016-11-23 65 views
1

我是Angular 2開發人員的新手,如果還不夠,我正在嘗試與Play框架集成爲後端。未找到「autoprefixer」任務的插件

我試圖按照有關設置了那種由丹尼斯Sinyakov一個偉大的職位:https://www.toptal.com/java/building-modern-web-applications-with-angularjs-and-play-framework

的想法是代理將進入到角應用到播放應用程序的請求。

它建議將'autoprefixer'任務作爲配置中的一部分與我遇到問題。 當我開始在角應用程序,我得到以下錯誤:

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' 
    ]); 
    }); 

欣賞關於如何安裝這個插件的所有提示,並進一步上對其進行配置,如果這是必要的。

+0

這裏可能相關的問題:HTTP://計算器.com/questions/36972598/grunt-jit-grunt-plugin-for-the-protractor-task-not-found嘗試加載grunt.loadNpmTasks('grunt-autoprefixer');沒有使用jit-grunt – Revive

+0

我已經運行'npm install grunt-autoprefixer --save-dev',添加了'grunt.loadNpmTasks('grunt-autoprefixer');'到Gruntfile.js,但我仍然得到錯誤**必需的配置屬性「autoprefixer.server」丟失。 **。你也可以詳細說明不使用jit-grunt嗎?我使用Intellij來運行任務。 –

回答

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

這意味着,JIT,咕嚕無法找到autoprefixer模塊 您可以更新的JIT咕嚕這樣的:

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

優化使用以上,但如果JIT-咕嚕仍然有問題,你可以嘗試添加:

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正確選擇和使用

+0

似乎'require('jit-grunt ...''似乎已經足夠了,並且我發現添加'require('load-grunt-tasks')(grunt)'',而不是,有人仍然會遇到問題,謝謝你的回答。 –