I think you will have to import your main.scss
into each of your other files and exclude main.scss
from your gulp.src
.
function style() {
return gulp.src(['./scss/**/*.scss', '!./scss/**/main.scss'])
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./css'))
.pipe(browserSync.stream());
}
'!./scss/**/main.scss'
this negates or excludes that file from being passes into this task - I assumed main.scss
was in the same folder as your other scss
files, if that is not the case you will have to modify the path.
Then @import
main.scss
into each of your 01.scss
, 02.scss
, etc. files:
@import "main.scss";
// also assumes in same folder
You can put this import statement anywhere in the file, if it is first any of main.scss
styles will be overridden by conflicting styles in the rest of the 0x.scss
file. If you put the import statement at the end, then main.scss
styles will override any previous conflicting styles.
Note: you should really be using @use
instead of @import
and gulp-dart-sass instead of gulp-sass
at this point. See sass @use rule.
// in your gulpfile.js
const sass = require('gulp-dart-sass');
// once installed
@use "main.scss";
// must be at top of each scss file, such as 01.scss
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…