所以我有一个很好的咕噜剧本:
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dev: {
options: {
sourceMap: false,
sourceComments: 'none',
errLogToConsole: true,
check: false,
precision: 1,
includePaths: [
'../Scripts/lib/bootstrap-sass-official/assets/stylesheets'
],
outputStyle: 'nested'
},
files: {
'../Content/styles/output/ModellingContent.css': '../Content/styles/ModellingContent.scss',
'../Content/styles/output/Configure.css': '../Content/styles/Configure.scss'
}
},
build: {
options: {
sourceMap: false,
includePaths: [
'../Scripts/lib/bootstrap-sass-official/assets/stylesheets'
],
outputStyle: 'compressed'
},
files: {
'../Content/styles/output/ModellingContent.css': '../Content/styles/ModellingContent.scss',
'../Content/styles/output/Configure.css': '../Content/styles/Configure.scss'
}
}
},
watch: {
css: {
files: '../Content/styles/**/*.scss',
tasks: [
'sass:dev'
],
options: {
spawn: false,
livereload: true
}
},
shared_config: {
files: '../Content/styles/global/_shared-vars.json',
tasks: [
'shared_config',
'sass:dev'
],
options: {
spawn: false,
livereload: true
}
}
},
shared_config: {
default: {
options: {
name: "globalStyle",
cssFormat: "dash",
jsFormat: "dash"
},
src: "../Content/styles/global/_shared-vars.json",
dest: [
"../Content/styles/global/_shared-vars.scss",
"../Content/styles/global/_shared-vars.js"
]
},
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-preen');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-shared-config');
grunt.registerTask('deploy', [
'preen',
'build'
]);
grunt.registerTask('build', [
'shared_config',
'sass:build'
]);
grunt.registerTask('watch', [
'default',
'watch'
]);
grunt.registerTask('default', [
'shared_config',
'sass:dev'
]);
}
但是当我运行它时,grunt只停留在sass:dev任务中并创建空的css文件。这就是我在控制台中找到的内容:
Running "shared_config:default" (shared_config) task
>> File: ../Content/styles/global/_shared-vars.scss created.
>> File: ../Content/styles/global/_shared-vars.js created.
Running "sass:build" (sass) task
我已经多次重新安装了所有东西,但我无法弄清楚问题。
答案 0 :(得分:0)
我不知道是否绝对需要这种嵌套,但是当我使用grunt-sass时,我将files
放在dist
内。 grunt-sass Usage example也是这样做的。
所以也许以下 sass:build 定义对你有用:
build: {
options: {
sourceMap: false,
includePaths: [
'../Scripts/lib/bootstrap-sass-official/assets/stylesheets'
],
outputStyle: 'compressed'
},
dist: {
files: {
'../Content/styles/output/ModellingContent.css': '../Content/styles/ModellingContent.scss',
'../Content/styles/output/Configure.css': '../Content/styles/Configure.scss'
}
}
}
答案 1 :(得分:0)
我发现我的变量配置错误了。它设置为$ size:$ size。 它没有报告我认为的错误,但它让我觉得它更严重。