Sass Gruntfile 中忽略的样式选项
Sass style options ignored in Gruntfile
我有以下 gruntfile
,它编译得很好,但是它似乎忽略了 style
选项并且只使用默认的 'nested' 样式。我试过 compressed
、expanded
和 compact
,结果都完全一样。
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'css/style.css' : 'scss/main.scss'
},
options: {
sourceMap: true,
style: 'expanded'
}
}
},
sass_globbing: {
your_target: {
files: {
'scss/_base.scss': 'scss/base/**/*.scss',
'scss/_layout.scss': 'scss/layout/**/*.scss',
'scss/_components.scss': 'scss/components/**/*.scss',
'scss/_theme.scss': 'scss/theme/**/*.scss'
},
options: {
useSingleQuoates: false
}
}
},
autoprefixer: {
dist: {
options : {
browsers: ['last 2 version','ie 8','ie 9','android 4']
},
files: {
'css/style.css' : 'css/style.css'
}
}
},
watch: {
options: {
livereload: true
},
css: {
files: '**/*.scss',
tasks: ['sass_globbing','sass','autoprefixer']
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass-globbing');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.registerTask('default',['watch']);
}
我正在使用:
- grunt-cli v1.2.0
- grunt v0.4.5
我试过对 scss 文件添加更改,删除样式表,生成一个具有不同名称的全新文件,运行 grunt sass --force
但它仍然生成相同的文件(并且它正在生成文件)。我也尝试过用 grunt sass --style compact --force
覆盖 grunt 中的样式,但仍然没有快乐。
我做错了什么?
根据 https://github.com/sindresorhus/grunt-sass#usage 上的文档,options
键上一级(将其移出 dist
):
grunt.initConfig({
sass: {
options: {
sourceMap: true,
style: 'compressed'
},
dist: {
...
}
}
}
希望对您有所帮助!
我有以下 gruntfile
,它编译得很好,但是它似乎忽略了 style
选项并且只使用默认的 'nested' 样式。我试过 compressed
、expanded
和 compact
,结果都完全一样。
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
files: {
'css/style.css' : 'scss/main.scss'
},
options: {
sourceMap: true,
style: 'expanded'
}
}
},
sass_globbing: {
your_target: {
files: {
'scss/_base.scss': 'scss/base/**/*.scss',
'scss/_layout.scss': 'scss/layout/**/*.scss',
'scss/_components.scss': 'scss/components/**/*.scss',
'scss/_theme.scss': 'scss/theme/**/*.scss'
},
options: {
useSingleQuoates: false
}
}
},
autoprefixer: {
dist: {
options : {
browsers: ['last 2 version','ie 8','ie 9','android 4']
},
files: {
'css/style.css' : 'css/style.css'
}
}
},
watch: {
options: {
livereload: true
},
css: {
files: '**/*.scss',
tasks: ['sass_globbing','sass','autoprefixer']
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-sass-globbing');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.registerTask('default',['watch']);
}
我正在使用:
- grunt-cli v1.2.0
- grunt v0.4.5
我试过对 scss 文件添加更改,删除样式表,生成一个具有不同名称的全新文件,运行 grunt sass --force
但它仍然生成相同的文件(并且它正在生成文件)。我也尝试过用 grunt sass --style compact --force
覆盖 grunt 中的样式,但仍然没有快乐。
我做错了什么?
根据 https://github.com/sindresorhus/grunt-sass#usage 上的文档,options
键上一级(将其移出 dist
):
grunt.initConfig({
sass: {
options: {
sourceMap: true,
style: 'compressed'
},
dist: {
...
}
}
}
希望对您有所帮助!