(Beginner post)
I used Grunt for this tree :
Gruntfile.js :
module.exports = function(grunt) {
grunt.initConfig({
sass: {
dist: {
options: {
style: 'expanded'
},
files: {
'css/style.css': 'Component/**/*.scss',
}
}
},
watch: {
css: {
files: 'Component/**/*.scss',
tasks: ['sass']
},
},
});
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['watch']);
}
It runs without any errors, but it don't take any file. The style.css still empty.
When I replace this line :
files: {
'css/style.css': 'Component/**/*.scss',
}
with :
files: {
'css/style.css': 'Component/header/header.scss',
}
Its takes the .css file in header/ correctly.
I don't have any error with either of these two syntaxes.
Any idea ?
You need to use the grunt files pattern to get all the files recursively in the sources folder:
To use Grunt file patterns you need to specify an object with options instead of the default setting in the form of
'destination': 'source'. The file pattern object has the following options:More about Grunt file patterns and minimatch file matching patterns.
Edit to achieve the desired result (have all the components compiled in to a single file), you will need to do the following:
Component/header/header.scsstoComponent/header/_header.scss. Files prefixed with_will not create any output (Sass default behavior).style.scss, containing only the reference to the files you want to merge in to your output css file. For each file add@import 'header/header';forheader/_header.scss. You don't need to add the extension or the_prefix.filesdefinition of yousass:disttask to:{ 'css/style.css' : ['Component/style.scss'] }Gruntfile.jswill now look like this:That will compile
Component/style.scss(containing the reference to all your components files) in tocss/style.css.