我如何在libsass工作流中使用奇点额外功能



如何在libsass工作流中使用Singularity Extras ?我指的是npm和gulp,而不是ruby。提前感谢。

这就是我如何用Gulp设置Singularitygs + Breakpoint + Compass(用于Drupal主题)。

全局安装gulpsudo npm install -g gulp

复制以下包。

{
  "name": "your_project_name",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "dependencies": {
    "browser-sync": "^2.9.3",
    "gulp": "^3.9.0",
    "gulp-autoprefixer": "^2.3.1",
    "gulp-plumber": "^1.0.1",
    "gulp-sass": "^2.0.4",
    "gulp-sourcemaps": "^1.5.2",
    "breakpoint-sass": "^2.6.1",
    "compass-mixins": "^0.12.7",
    "singularitygs": "^1.6.2",
    "gulp-watch": "^4.3.5"
  },
  "devDependencies": {
    "gulp-cssmin": "^0.1.7",
    "gulp-strip-css-comments": "^1.2.0",
    "gulp-uglify": "^1.4.1",
    "gulp-uncss": "^1.0.3",
    "modularscale-sass": "^2.1.1",
    "node-sass-globbing": "0.0.23"
  },
  "scripts": {},
  "author": "",
  "license": "ISC"
}

目录下的cd,运行npm install

第二步:像这样创建并编辑你的gulpfile.js:
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var importer = require('node-sass-globbing');
var plumber = require('gulp-plumber');
var browserSync = require('browser-sync').create();
var cssmin = require('gulp-cssmin');
var uncss = require('gulp-uncss');
var stripCssComments = require('gulp-strip-css-comments');
var uglify = require('gulp-uglify');
var sass_config = {
  importer: importer,
  includePaths: [
    'node_modules/breakpoint-sass/stylesheets/',
    'node_modules/singularitygs/stylesheets/',
    'node_modules/modularscale-sass/stylesheets',
    // 'node_modules/singularity-extras/stylesheets/',
    'node_modules/compass-mixins/lib/'
  ]
};
gulp.task('uglify', function() {
  return gulp.src('js/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('js_min'));
});
gulp.task('browser-sync', function() {
    browserSync.init({
        injectChanges: true,
        proxy: "127.0.0.1/your_project_folder"
    });
    gulp.watch("./sass/**/*.scss", ['sass']);
    gulp.watch("./css/**/*.css").on('change', browserSync.reload);
    gulp.watch("./js/**/*.js", ['uglify']).on('change', browserSync.reload);
});
gulp.task('sass', function () {
  gulp.src('./sass/**/*.scss')
    .pipe(plumber())
    //.pipe(sourcemaps.init())
    .pipe(sass(sass_config).on('error', sass.logError))
    .pipe(autoprefixer({
      browsers: ['last 2 version']
    }))
    //.pipe(sourcemaps.write('.'))
    .pipe(stripCssComments({preserve: false}))
    .pipe(gulp.dest('./css'))
    // .pipe(uncss({
    //       html: ['./html/**/*.html']
    //   }))
    .pipe(cssmin())
    .pipe(gulp.dest('./css'));
});
gulp.task('default', ['sass', 'uglify', 'browser-sync']);

第三:要求在你的"theme.styles.scss"的顶部有以下内容:

@import "compass";
@import 'modular-scale';
@import "singularitygs";
@import "singularity-extras";
@import "breakpoint";
第四:不要忘记在你的"theme.styles"中包含每一个部分。
@import "compass";
@import 'modular-scale';
@import "singularitygs";
@import "singularity-extras";
@import "breakpoint";
@import "sass/variables/**/*.scss";
@import "sass/abstractions/**/*.scss";
@import "sass/base/**/*.scss";
@import "sass/components/**/*.scss";

如果您在Drupal和browserSync中遇到任何错误(白屏死机),您可以在主题的根文件夹中运行以下命令:

find node_modules -type f -name '*.info' | xargs rm

这会删除node_modules的.info文件,这些文件会给Drupal带来问题。参见:https://drupal.stackexchange.com/questions/126880/how-do-i-prevent-drupal-raising-a-segmentation-fault-when-using-a-node-js-themin

相关内容

  • 没有找到相关文章

最新更新