所以我有一个运行良好的 grunt 脚本:
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
我已经重新安装了几次,但我无法找出问题所在。