[英]Compiling SASS files using Grunt creates an unnecessary folder
So I have been trying to create my first compiled css files using grunt and sass, and i am having a problem that I cant figure it out. 所以我一直在尝试使用grunt和sass创建我的第一个已编译的CSS文件,但是我遇到了一个我无法弄清的问题。
Every time that I run the sass task, an unnecessary "sass" folder is created inside of my css folder: 每次我运行sass任务时,都会在css文件夹中创建一个不必要的“ sass”文件夹:
This is how it looks: 它是这样的:
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']);
}; };
And this is how my folder looks after I run the task: 这是运行任务后文件夹的外观:
/SASS/somefile.scss
/CSS/SASS/somefile.css
The SASS folder it should not be there, the result i expect is: SASS文件夹不应存在,我期望的结果是:
/SASS/somefile.scss
/CSS/somefile.css
Thanks in advance! 提前致谢!
Create a SASS folder under your CSS folder. 在CSS文件夹下创建一个SASS文件夹。 Your somefile.scss file move into SASS folder then run. 您的somefile.scss文件移动到SASS文件夹中,然后运行。
like as : 像:
CSS/ CSS /
SASS/somefile.scss SASS / somefile.scss
The problem is due to your parameters for building the files
object dynamically . 该问题是由于您用于动态生成files
对象的参数所致。 You need to set the cwd
parameter: "All src
matches are relative to (but don't include) this path." 您需要设置cwd
参数: “所有src
匹配都相对于(但不包括)此路径。”
files: [{
expand: true,
cwd: 'sass/',
src: '*.scss',
dest: 'css/',
ext: '.css'
}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.