gpt4 book ai didi

javascript - grunt-autoprefixer 设置

转载 作者:太空宇宙 更新时间:2023-11-04 02:22:51 27 4
gpt4 key购买 nike

我对 grunt(以及一般的 npm)还很陌生,所以如果我错过了一些明显的东西,请原谅我!

我正在尝试设置我的 gruntfile(在我开始这个特殊挑战之前它一直工作得很好)来使用 autoprefixer 插件,我按照此博客 http://grunt-tasks.com/autoprefixer/ 上的说明进行操作。但当我尝试初始化 grunt 时收到此错误:

 $ grunt

Running "postcss:dist" (postcss) task

Warning: Cannot read property 'postcss' of undefined Use --force to continue.

Aborted due to warnings.

这是我的 gruntfile :

module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.loadNpmTasks('grunt-contrib-watch');

grunt.loadNpmTasks('grunt-contrib-compass');

var autoprefixer = require('autoprefixer-core');

require('load-grunt-tasks')(grunt);

grunt.initConfig ({

uglify: {

my_target: {

files: {

'_/js/script.js' : ['_/components/js/*.js']

} //files

} //my_target

}, //uglify

compass: {

dev: {

options: {

config: 'config.rb'

} //options

}//dev

}, //compass

watch: {

options: {livereload: true},

scripts: {

files: ['_/components/js/*.js'],

tasks: ['uglify']

}, //script

sass: {

files: ['_/components/sass/*.scss'],

tasks: ['compass:dev']

}, //sass

html: {

files: ['*.html'],

}

}, //watch

postcss: {

options: {

processors: [

autoprefixer({

browers: ['> 0.5%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']

}).postcss

]

},

dist: {

files: {

'_/css/styles.css': '_/components/sass/*.scss'

}

}

}

}); //initConfig

grunt.registerTask('default', 'watch', ['postcss']);

} //exports

我错过了什么吗? (这显然是一些愚蠢的事情,比如放错了逗号,不是吗!!)提前致谢

最佳答案

好吧,如果有人偶然发现这个问题并且有类似的问题,这里是我的 gruntfile,它显示了我如何解决这个问题。

module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig ({
uglify: {
my_target: {
files: {
'_/js/script.js' : ['_/components/js/*.js']
} //files
} //my_target
}, //uglify
compass: {
dev: {
options: {
config: 'config.rb'
} //options
}//dev
}, //compass
watch: {
options: {livereload: true},
scripts: {
files: ['_/components/js/*.js'],
tasks: ['uglify']
}, //script
sass: {
files: ['_/components/sass/*.scss'],
tasks: ['compass:dev']
}, //sass
html: {
files: ['*.html'],
}
}, //watch
postcss: {
options: {
map: true,
processors: [
require('autoprefixer-core')({
browsers: ['last 2 versions']
})
]
},
dist: {
src: '_/css/*.css'
}
}
}); //initConfig
grunt.registerTask('default', 'watch', ['postcss:dist']);
} //exports

关于javascript - grunt-autoprefixer 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32214555/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com