Giter VIP home page Giter VIP logo

gulp-css's Introduction

gulp-css

A gulp plugin for css transport and concat

NPM Version Download Status Dependencies

Usage

const gulp = require('gulp');
const css = require('@nuintun/gulp-css');
const { join, relative } = require('path');

// Fixed css resource path
function onpath(path, property, file, wwwroot) {
  if (/^[^./\\]/.test(path)) {
    path = './' + path;
  }

  if (path.startsWith('.')) {
    path = join(dirname(file), path);
    path = relative(wwwroot, path);
    path = '/' + path;
    path = path.replace(/\\+/g, '/');
  }

  path = path.replace('assets/', 'online/');

  return path;
}

// Task
gulp.task('default', function() {
  gulp
    .src('assets/css/**/*.css')
    .pipe(css({ onpath: onpath }))
    .pipe(gulp.dest('online/css'));
});

API

css(options)

options
  • root String

    网站根目录。

  • map Function

    配置模块 ID 映射(返回的映射字符串必须符合文件路径规则,会同步更新模块 ID 和 输出文件名)。

  • combine Boolean|Function

    是否合并样式。

  • onpath Function

    样式文件中的资源文件路径处理回调函数。

  • onbundle Function

    模块合并完成后回调函数。

  • plugins Array[Object]

    自定义模块转换插件,有 moduleDidLoaded, moduleDidParsed, moduleDidCompleted 三个生命周期提供调用处理。

gulp-css's People

Contributors

nuintun avatar

Watchers

 avatar

Forkers

frank7755

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.