2015-02-08 118 views
0

我正在使用grunt-cdnify作爲CDN我的網絡資產。在REMADME.md文件中,我正在使用下面的配置。使用grunt-cdnify時出現錯誤

cdnify: { 
    makeItAws: { 
    options: { 
     base: 'http://my.cdn.com/' 
    }, 
    files: [{ 
     expand: true, 
     cwd: '<%= app.dist %>', 
     src: '**/*.{css,html,js}', 
     dest: '<%= app.dist %>' 
    }] 
    } 
}, 

我咕嚕任務寄存器

grunt.registerTask('build', [ 
'clean:dist', 
'wiredep', 
'useminPrepare', 
'concurrent:dist', 
'autoprefixer', 
'concat', 
'ngAnnotate', 
'copy:dist', 
'cdnify', 
'cssmin', 
'uglify', 
'filerev', 
'usemin', 
'htmlmin', 
'cdnify' 
]); 

我收到此錯誤以下

Anjums-MacBook-Pro:project anjum$ grunt cdnify 
Running "cdnify:makeItAws" (cdnify) task 

Warning: An error occurred while processing a template 
(Cannot read property 'dist' of undefined). Use --force to continue. 

Aborted due to warnings. 


Execution Time (2015-02-08 08:42:51 UTC) 
loading tasks  3ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 33% 
cdnify:makeItAws 5ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 56% 
Total 9ms 

任何想法,我錯了?請指導我。謝謝

+0

的cdnify任務是重寫你的HTML和CSS發現靜態資源的URL。一旦請檢查您應用中的所有網址(CDN),看看它們是否指向正確的地址? – Rajeshwar 2015-02-08 10:44:26

+0

'grunt.registerTask('build',...)'註冊一個名爲'build'的任務,該任務應該使用'grunt build'運行。你註冊了一個名爲grunt.registerTask('cdnify',...)的任務嗎? – 2015-05-26 19:05:02

回答

1

這不是cdnify的問題,這是因爲你的配置變量「app」是未定義的。請確保您在您的gruntfile的配置部分正確定義的應用程序,例如:

grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 

    app: { 
     dist: 'dist' 
    }, 
    etc... 
0

或許有些任務是缺少本地NPM包,請嘗試

npm install 

從您package.json安裝的軟件包文件,然後嘗試再次grunt cdnify

0

要運行的任務,因爲grunt cdnify必須註冊cdnify咕嚕的任務,因爲

grunt.registerTask('cdnify', [ 
    'cdnify' 
]); 

Gruntfile.js