我知道GULP-SASS應該是微不足道的,但如果我們可以使事情複雜化,爲什麼不行?Gulp sass將不同的文件夾整合到一個CSS文件中
好吧,看來我工作的項目有一個「特定」的結構,我必須習慣它。它是這樣的:
-static
-app
-components
-component1
-styles
-component1.scss
-component2
-styles
-component2.scss
...
在與應用程序相同的水平我揮手的一個子項目...可以稱之爲網絡:
-static
-web
-res
-static
-app
-components
-component3
-style
-component3.scss
現在到了最有趣的部分:黑客如何創建一個來自這個混亂的單個CSS文件?我試過沒有任何運氣:
// Setting up the sass task
gulp.task('sass', function(){
// Taking the path from the above object
var sassApp = gulp.src(paths.styles.filesApp)
// Sass options - make the output compressed and add the source map
// Also pull the include path from the paths object
.pipe(sass({
outputStyle: 'compact', //compressed
//sourceComments: 'map',
includePaths : [paths.styles.srcApp]
}))
// If there is an error, don't stop compiling but use the custom displayError function
.on('error', function(err){
displayError(err);
})
// Pass the compiled sass through the prefixer with defined
.pipe(prefix(
'last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'
))
// Funally put the compiled sass into a css file
.pipe(gulp.dest(paths.styles.dest));
var sassWeb = gulp.src(paths.styles.filesWeb)
// Sass options - make the output compressed and add the source map
// Also pull the include path from the paths object
.pipe(sass({
outputStyle: 'compact',
//sourceComments: 'map',
includePaths : [paths.styles.srcWeb]
}))
// If there is an error, don't stop compiling but use the custom displayError function
.on('error', function(err){
displayError(err);
})
// Pass the compiled sass through the prefixer with defined
.pipe(prefix(
'last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'
))
// Funally put the compiled sass into a css file
.pipe(gulp.dest(paths.styles.dest));
return
gulpMerge(sassApp, sassWeb)
.pipe(concat('all-css.css'))
.pipe(gulp.dest(paths.styles.dest));
});
我想所有的.scss文件移動到一個文件夾,並用一口-useref https://www.npmjs.com/package/gulp-useref – Mills