B
B
bulkmaker2017-09-28 22:05:28
Sass
bulkmaker, 2017-09-28 22:05:28

What is the correct way to change bootstrap 4 beta variables in Sass?

I use the start template from WebDesignMaster https://github.com/agragregra/optimizedhtml-start-...
Connected bootstrap 4 beta to it via sass. In my template, in the _vars.sass file, I want to change the bootstrap variables and I can't do it.
if a simple type variable:
$grid-gutter-width: 20px
changes without problems and works
But with more complex variables there are already problems:

$container-max-widths: (
  sm: 420px,
  md: 720px,
  lg: 960px
);

such code in .sass already leads to an error.
Maybe convert this file from .sass to .scss ? Just renaming didn't work. Maybe somehow you need to change gulpfile.js? there he is:
var gulp           = require('gulp'),
    gutil          = require('gulp-util' ),
    sass           = require('gulp-sass'),
    browserSync    = require('browser-sync'),
    concat         = require('gulp-concat'),
    uglify         = require('gulp-uglify'),
    cleanCSS       = require('gulp-clean-css'),
    rename         = require('gulp-rename'),
    del            = require('del'),
    imagemin       = require('gulp-imagemin'),
    cache          = require('gulp-cache'),
    autoprefixer   = require('gulp-autoprefixer'),
    ftp            = require('vinyl-ftp'),
    notify         = require("gulp-notify"),
    rsync          = require('gulp-rsync');

// Пользовательские скрипты проекта

gulp.task('common-js', function() {
  return gulp.src([
    'app/js/common.js',
    ])
  .pipe(concat('common.min.js'))
  .pipe(uglify())
  .pipe(gulp.dest('app/js'));
});

gulp.task('js', ['common-js'], function() {
  return gulp.src([
    'app/libs/jquery/jquery-3.2.1.min.js', // Берем jQuery
    'app/libs/bootstrap/js/popper.min.js', // Берем jQuery
    'app/libs/bootstrap/js/bootstrap.min.js', // Берем jQuery
    'app/libs/magnific-popup/dist/jquery.magnific-popup.min.js', // Берем Magnific Popup
    'app/js/common.js', // Всегда в конце
    ])
  .pipe(concat('scripts.min.js'))
  // .pipe(uglify()) // Минимизировать весь js (на выбор)
  .pipe(gulp.dest('app/js'))
  .pipe(browserSync.reload({stream: true}));
});

gulp.task('browser-sync', function() {
  browserSync({
    server: {
      baseDir: 'app'
    },
    notify: false,
    // tunnel: true,
    // tunnel: "projectmane", //Demonstration page: http://projectmane.localtunnel.me
  });
});

gulp.task('sass', function() {
  return gulp.src('app/sass/**/*.sass')
  .pipe(sass({outputStyle: 'expand'}).on("error", notify.onError()))
  .pipe(rename({suffix: '.min', prefix : ''}))
  .pipe(autoprefixer(['last 15 versions']))
  .pipe(cleanCSS()) // Опционально, закомментировать при отладке
  .pipe(gulp.dest('app/css'))
  .pipe(browserSync.reload({stream: true}));
});

gulp.task('watch', ['sass', 'js', 'browser-sync'], function() {
  gulp.watch('app/sass/**/*.sass', ['sass']);
  gulp.watch(['libs/**/*.js', 'app/js/common.js'], ['js']);
  gulp.watch('app/*.html', browserSync.reload);
});

gulp.task('imagemin', function() {
  return gulp.src('app/img/**/*')
  .pipe(cache(imagemin()))
  .pipe(gulp.dest('dist/img')); 
});

gulp.task('build', ['removedist', 'imagemin', 'sass', 'js'], function() {

  var buildFiles = gulp.src([
    'app/*.html',
    'app/.htaccess',
    ]).pipe(gulp.dest('dist'));

  var buildCss = gulp.src([
    'app/css/main.min.css',
    ]).pipe(gulp.dest('dist/css'));

  var buildJs = gulp.src([
    'app/js/scripts.min.js',
    ]).pipe(gulp.dest('dist/js'));

  var buildFonts = gulp.src([
    'app/fonts/**/*',
    ]).pipe(gulp.dest('dist/fonts'));

});

gulp.task('deploy', function() {

  var conn = ftp.create({
    host:      'hostname.com',
    user:      'username',
    password:  'userpassword',
    parallel:  10,
    log: gutil.log
  });

  var globs = [
  'dist/**',
  'dist/.htaccess',
  ];
  return gulp.src(globs, {buffer: false})
  .pipe(conn.dest('/path/to/folder/on/server'));

});

gulp.task('rsync', function() {
  return gulp.src('dist/**')
  .pipe(rsync({
    root: 'dist/',
    hostname: '[email protected]',
    destination: 'yousite/public_html/',
    archive: true,
    silent: false,
    compress: true
  }));
});

gulp.task('removedist', function() { return del.sync('dist'); });
gulp.task('clearcache', function () { return cache.clearAll(); });

gulp.task('default', ['watch']);

I would really appreciate clarification

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zooks, 2017-09-29
@bulkmaker

For Sass syntax, maps are specified on a single line via identification.

$map: (key1: value1, key2: value2, key3: value3)

$container-max-widths: (sm: 420px, md: 720px, lg: 960px)

There is a built-in converter to Ruby Sass:
where is css/the folder with .scss files

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question