如果我有一个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