[英]Gruntfile Aborting file
我已下載基礎5,但在將默認配置添加到插件時遇到問題。 我從控制台的角度理解插件的安裝。 但是,在包含和注冊任務之后,我努力正確編寫Gruntfile.js代碼
Gruntfile.js
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
watch: {
options: {
livereload: true
},
css: {
files: {
'css/app.css': 'scss/apps.css',
'css/custom.css': 'scss/custom.scss'
},
tasks: ['sass', 'concat'],
options: {
spawn: false,
}
},
scripts: {
files: ['js/dev/*.js'],
tasks: ['jshint', 'concat', 'uglify'],
options: {
spawn: false,
}
}
},
sass: {
options: {
includePaths: ['bower_components/foundation/scss']
},
dist: {
options: {
outputStyle: 'nested'
},
expand: true,
cwd: 'scss/',
src: {
'css/app.css': 'scss/apps.css',
'css/custom.css': 'scss/custom.scss'
},
dest: 'css/',
ext: '.css'
}
},
jshint: {
src: ['Gruntfile.js', 'js/dev/script.js'],
options: {
jshintrc: '.jshintrc',
}
},
uglify: {
build: {
files: {
'js/dev/plugins/*.js': ['js/dev/plugins.min.js'],
'js/dev/script.min.js': ['js/dev/script.min.js']
}
}
},
concat : {
bar: {
'js/dev/script.min.js': ['js/build/script.min.js?<%= pkg.version %>']
}
},
imagemin: {
static: {
options: {
optimizationLevel: 3
},
files: {
'lossy-images/*.png': 'images/*.png',
'lossy-images/*.jpg': 'images/*.jpg',
'lossy-images/*.gif': 'images/*.gif'
}
},
dynamic: {
files: [{
expand: true,
cwd: 'images/',
src: ['**/*.{png,jpg,gif}'],
dest: 'lossy-images/'
}]
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.registerTask('build', ['sass']);
grunt.registerTask('default', ['build','watch', 'jshint', 'concat', 'uglify', 'imagemin']);
};
的package.json
{
"name": "example-site",
"version": "0.0.1",
"devDependencies": {
"node-sass": "~0.7.0",
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-sass": "~0.8.0",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.3.1",
"grunt-contrib-imagemin": "~0.5.0"
}
}
.jshitrc內容
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"boss": true,
"eqnull": true,
"node": true,
"browser" : true,
"globals": {
"jQuery": true,
"require" : true,
"define" : true,
"requirejs" : true,
"describe" : true,
"expect" : true,
"it" : true,
"module" : true,
}
}
Livereload - HTML代碼
<script src="//localhost:35729/livereload.js"></script>
結論:
實時重新加載不起作用(我已經安裝了chrome擴展)。 我收到以下錯誤:
Running "sass:dist" (sass) task
Warning: Object #<Object> has no method 'indexOf' Use --force to continue.
Aborted due to warnings.
我還沒有為我的mixin需要包括指南針/自動修復器。 如果您花時間滾動或閱讀,謝謝。
我歡迎任何幫助!
您應該嘗試更改sass部分,如下所示:
sass: {
dist: {
options: {
outputStyle: 'nested'
},
files: [
{src: 'css/app.css', dest: 'scss/apps.css'},
{src: 'css/custom.css', dest: 'scss/custom.scss'}
]
}
}
有關文件對象格式選項的更多信息,請參見此處:
http://gruntjs.com/configuring-tasks#files-object-format
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.