如果我有一個components/root/sass/index.scss
以內的文件,我該如何將它編譯爲components/root/styles/index.css
?簡而言之,我想用styles
代替sass
,即如果我有一個文件在components/second/sass/file.scss
,它會編譯爲components/second/styles/file.css
。Gulp將SASS編譯爲相對子文件夾
這是我當前的代碼在gulpfile.js
:
var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('sass', function() {
return gulp.src('components/**/sass/*.scss', {base: "./"})
.pipe(sass())
.pipe(gulp.dest('../styles/'));
})
gulp.task('default', function() {
gulp.watch('components/**/sass/*.scss', ['sass']);
});
感謝您的回覆,但它將它放在'styles/index.css/index.css'文件中? – think123
我剛剛編輯了一個使用gulp-rename模塊的解決方案,因爲它看起來更適合「吞噬方式」,你可以試試這個嗎? – ElMesa
我嘗試了「components/root/sass/index.scss」並獲取「components/root/styles/index.css」。如果它不起作用分享有問題的例子來嘗試不同的替代品。 – ElMesa