I use gulp-sass to compile scss files. In one directory is the main file style.scss and the file that is imported into the main print.scss . main.scss compiles normally without errors and takes values in the print.scss file, but as soon as I want to save the changes in the print.scss file, it gives an error:
events.js:154 throw er; // Unhandled 'error' event ^ Error: app\scss\style.scss Error: File to import not found or unreadable: _print Parent style sheet: stdin on line 3 of stdin >> @import "_print"; ^ at options.error (E:\ready\node_modules\node-sass\lib\index.js:277:32) Below is the file gilfile.js and other files that can help to solve this problem.
var gulp = require('gulp'); var sass = require('gulp-sass'); var sassGlob = require('gulp-sass-glob'); // var sass = require('gulp-ruby-sass'); var cssGlobbing = require('gulp-css-globbing'); var autoprefixer = require('gulp-autoprefixer'); var sourcemaps = require('gulp-sourcemaps'); var browserSync = require('browser-sync'); var useref = require('gulp-useref'); var uglify = require('gulp-uglify'); var gulpIf = require('gulp-if'); var cleanCSS = require('gulp-clean-css'); var del = require('del'); var runSequence = require('run-sequence'); gulp.task('browserSync', function() { browserSync({ server: { baseDir: 'app' } }) }) gulp.task('sass', function(){ return gulp.src('app/scss/**/*.scss') .pipe(sourcemaps.init()) // .pipe(cssGlobbing({ // extensions: ['.scss'] // })) .pipe(sassGlob()) .pipe(sass()) .pipe(autoprefixer({ browsers: ['last 2 versions'], cascade: false })) .pipe(cleanCSS({compatibility: 'ie8'})) .pipe(sourcemaps.write('.')) .pipe(browserSync.reload({ stream: true })) .pipe(gulp.dest('app/css')); }) gulp.task('useref', function(){ return gulp.src('app/*.html') .pipe(useref()) // Minifies only if it's a JavaScript file .pipe(gulpIf('*.js', uglify())) .pipe(gulp.dest('dist')) }) gulp.task('clean', function() { return del.sync('dist').then(function(cb) { return cache.clearAll(cb); }); }) gulp.task('clean:dist', function() { return del.sync(['dist/**/*', '!dist/images', '!dist/images/**/*']); }); gulp.task('fonts', function() { return gulp.src('app/fonts/**/*') .pipe(gulp.dest('dist/fonts')) }) // Watchers gulp.task('watch', ['browserSync', 'sass'], function(){ gulp.watch('app/scss/**/*.scss', ['sass']); gulp.watch('app/*.html', browserSync.reload); gulp.watch('app/js/**/*.js', browserSync.reload); // Other watchers }) gulp.task('default', function(callback) { runSequence(['sass', 'browserSync', 'watch'], callback ) }) gulp.task('build', function(callback) { runSequence( 'clean:dist', // ['sass', 'useref', 'images', 'fonts'], ['sass', 'useref', 'fonts'], callback ) }) Common html-code element:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <!--build:css css/style.min.css --> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/print.css"> <!-- endbuild --> </head> <body> <header> <h1>Добро пожаловать!</h1> </header> <section> <h2>Секция документа</h2> <p>Проверяем компиляцию файлов</p> <p>Не обьеденяет в один css несколько фалов</p> </section> <section> <h1>Всего две команды:</h1> <p>gulp build</p> <p>gulp default</p> </section> <section class="flex"> <div>1</div> <div>2</div> <div>3</div> </section> <section class="print"> <h2>ЭТО, ПРИНТ</h2> <a href="#"> <div> <p>Раздумье</p> </div> </a> </section> <!--build:js js/main.min.js --> <script src="js/carousel.js"></script> <script src="js/gallery.js"></script> <script src="js/nav.js"></script> <!-- endbuild --> </body> </html> Item code where .scss ( style.scss ) works:
@import "_print"; @import "_mixins"; .testing { width: pecentage(5/7); } body { background: grey; h1 { color:white; @include font-size(40px); background: green; } } section { font-size: 40px; } .flex { display: flex; justify-content: space-between; div { width: 30%; background: orange; &:hover { background: red; } } } How to fix it and what is wrong here?