A
A
Alexon Classic2018-10-23 01:10:08
gulp.js
Alexon Classic, 2018-10-23 01:10:08

Gupl. Why such strange behavior (newbie question)?

My gulpfile.js:
var gulp = require('gulp'),
    sass = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    sourcemaps = require('gulp-sourcemaps'),
    purge = require('gulp-css-purge'),
    browserSync = require('browser-sync');

var scssSrcFiles = ('templates/seb_minima/sass/**/*.scss'),
    cssFolderDest = ('templates/seb_minima/css'),
    PHPPath = ('/templates/**/*.php'),
    reload = browserSync.reload,
    supported = ['last 20 versions', '> 1%', 'IE >= 1', 'Firefox >= 1', 'Opera >= 1', 'Android >= 1', 'iOS >= 1', 'Safari >= 1'];

gulp.task('SASS to CSS', function () {
    return gulp.src(scssSrcFiles)
    .pipe(sourcemaps.init({loadMaps: true}))
        .pipe(sass({errLogToConsole: true, outputStyle: 'expanded'}).on('error', sass.logError))
        .pipe(purge({
            trim: true,
            shorten: true,
            format: true,
            bypass_media_rules: true,
            special_convert_rem_font_size: true,
            verbose: true,
            shorten_border: true
        }))
        .pipe(autoprefixer({browsers: supported, add: true, cascade: false, grid: true}))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(cssFolderDest))
        .pipe(reload({stream: true}))
    return cache.clearAll();
});

gulp.task('browser-sync', function () {
    browserSync({
        proxy: {
            target: "http://my_site/"
        },
        browser: ["chrome"],
        notify: false,
    });
});

gulp.task('watch', function () {
    gulp.watch(scssSrcFiles, ['SASS to CSS']);
    gulp.watch(PHPPath).on('change', reload);
});

gulp.task('default', ['SASS to CSS', 'browser-sync', 'watch']);

Works without issue. But!
For ease of reading (comparison), here are the 2 lines:
scssSrcFiles = ('templates/seb_minima/sass/**/*.scss'),
    cssFolderDest = ('templates/seb_minima/css'),

I should change the name of the template "seb_minima" in the scssSrcFiles and cssFolderDest variables to something else (which is in the project), for example, to "my_tmpl":
scssSrcFiles = ('templates/my_tmpl/sass/**/*.scss'),
    cssFolderDest = ('templates/my_tmpl/css'),

I get an error in the console right away:
CSS Parser Error: probably have something funny in your CSS, change it then please try again.
Reason: property missing ':'
Line: 27
Column: 1
Filename: demo/test1.css

What kind of fruit is this demo / test1 . css ... I don't get it. In my project, I don’t have it anywhere (except for gulp-css-purge itself) ... But that’s not the question ...
Question :
Why, when one path is used, there are no errors and problems - no, as soon as I change the path - getting an error...?
P. _ S. _
The directory structure in the "seb_minima" template and in the "my_tmpl" template is the same.
The SASS folder is located at the root of the template. i.e.:
  • templates/seb_minima/sass and
  • templates/my_tmpl/sass

The CSS folder is also located at the root of the template:
  • templates/seb_minima/css
  • templates/my_tmpl/css

That is, everything is one to one, only the name of the templates (folders) is different Thank you in
advance for your answers

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Velichko, 2018-11-02
@Zoxon

By the fact that it does not find the templates/seb_minima/** folder
Change the paths in gulpfile.js
For example, to these

var scssSrcFiles = ('templates/*/sass/**/*.scss'),
cssFolderDest = ('templates/*/css'),
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question