使用 Grunt 编译 SASS 个文件会创建一个不必要的文件夹
Compiling SASS files using Grunt creates an unnecessary folder
所以我一直在尝试使用 g运行t 和 sass 创建我的第一个编译的 css 文件,但我遇到了一个我无法解决的问题。
每次我 运行 执行 sass 任务时,都会在我的 css 文件夹中创建一个不必要的 "sass" 文件夹:
这是它的样子:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch:{
sass:{
files:['sass/*.scss'],
task:['sass']
}
},
sass: {
dist: {
files: [{
expand: true,
cwd: '',
src: ['sass/*.scss'],
dest: 'css/',
ext: '.css'
}]
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['sass']);
};
这就是我的文件夹在 运行 任务后的样子:
/SASS/somefile.scss
/CSS/SASS/somefile.css
SASS 文件夹不应该存在,我期望的结果是:
/SASS/somefile.scss
/CSS/somefile.css
提前致谢!
在您的 CSS 文件夹下创建一个 SASS 文件夹。您的 somefile.scss 文件移至 SASS 文件夹,然后 运行。
喜欢:
CSS/
SASS/somefile.scss
问题是由于 building the files
object dynamically 的参数引起的。您需要设置cwd
参数:"All src
matches are relative to (but don't include) this path."
files: [{
expand: true,
cwd: 'sass/',
src: '*.scss',
dest: 'css/',
ext: '.css'
}]
所以我一直在尝试使用 g运行t 和 sass 创建我的第一个编译的 css 文件,但我遇到了一个我无法解决的问题。
每次我 运行 执行 sass 任务时,都会在我的 css 文件夹中创建一个不必要的 "sass" 文件夹:
这是它的样子:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
watch:{
sass:{
files:['sass/*.scss'],
task:['sass']
}
},
sass: {
dist: {
files: [{
expand: true,
cwd: '',
src: ['sass/*.scss'],
dest: 'css/',
ext: '.css'
}]
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['sass']);
};
这就是我的文件夹在 运行 任务后的样子:
/SASS/somefile.scss
/CSS/SASS/somefile.css
SASS 文件夹不应该存在,我期望的结果是:
/SASS/somefile.scss
/CSS/somefile.css
提前致谢!
在您的 CSS 文件夹下创建一个 SASS 文件夹。您的 somefile.scss 文件移至 SASS 文件夹,然后 运行。
喜欢:
CSS/
SASS/somefile.scss
问题是由于 building the files
object dynamically 的参数引起的。您需要设置cwd
参数:"All src
matches are relative to (but don't include) this path."
files: [{
expand: true,
cwd: 'sass/',
src: '*.scss',
dest: 'css/',
ext: '.css'
}]