• Base64 + Stylus = как сделать?

    @zenwarr
    Просто нужно присвоить url другую функцию, которая будет использоваться вместо нее. Если использовать gulp, то это делается вот так:

    gulpfile.js
    var gulp = require('gulp');
    var stylus = require('gulp-stylus');
    
    var styles_input = 'src/styles';
    var styles_output = 'css';
    
    gulp.task('stylus', function() {
      var stream = gulp.src(styles_input + '/*.styl')
          .pipe(stylus(
                {
                  url: 'embedurl'
                }))
          .pipe(gulp.dest(styles_output));
    });
    
    gulp.task('default', function() {
      gulp.start('stylus');
    });


    Здесь передается стандартная функция-замена url стилуса, которую accord, который занимается вызовом стилуса, обозвал embedurl, но можно, в том числе, написать свою замену.

    и, собственно, style.styl
    @charset "UTF-8";
    
    url = embedurl
    
    body
      background url(../img/site-logo.png)


    Получается вот что:
    @charset "UTF-8";
    body {
      background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAAtCAYAAADr0SSvAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMDE0IDc5LjE1Njc5NywgMjAxNC8wOC8yMC0wOTo1MzowMiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly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F7NTKljZgM9Hajm3UJdClvF36KiikvOSvHlflLPpGH08XvehTXDgcDd616kP8/CSWMLyDlJKEXyZED9b98oBzvIL1zYsjDXZltfKAktBrqI71HkqkgiJ/7ho5rrSAyoTyPie7ky5OgJDRLuE6SpXFL2wjpHGJTHnqh8lMJuzSVZxFYHelc62GcO+PoXfRRkLCK+oQwXDnWe6wkB0H2YnTd5sFve5NciTiV+zPYGrwHaZvlUB72JNyIxVlC7vM4lWR5aErTCbU20lbTyd4NBbgcQwmUjkP4jUL63xSI49l9TrrUUCh0n1D77Y6NDr/zRyc8LiJ57VZB82O/nY9dOpCFU+lcVS7psSwcFx3IOzHTQXp5Xq+qXZaXEP/GKHFx7aiEMgXJzQ22HwcI4LmJFSBAoCABAgQKEiBAoCABAgQIFCRAAGdICYVCwTRWgAAW+E+AAQDbwJb4UzV9MQAAAABJRU5ErkJggg==");
    }
    Ответ написан
    Комментировать
  • Литературу по подходам к unit-тестированию javascript?

    @dhomich
    Посмотрите «Test-Driven JavaScript Development »
    Ответ написан
    Комментировать