我正在使用grunt-cdnify来获取CDN我的网络资源。我在REMADME.md文件中使用以下配置。
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 :(得分:1)
这不是cdnify的问题,因为您的配置变量“app”未定义。确保在gruntfile的config部分中正确定义app,例如:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
app: {
dist: 'dist'
},
etc...
答案 1 :(得分:0)
您的本地npm包可能缺少某些任务,请尝试
npm install
要从您package.json
文件安装软件包,请再次尝试grunt cdnify
答案 2 :(得分:0)
要将任务作为grunt cdnify
运行,您必须将cdnify
grunt任务注册为
grunt.registerTask('cdnify', [
'cdnify'
]);
在Gruntfile.js