Blame view

build/build-style.js 1.86 KB
7fa943eb   梁灏   init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
  /**
   * 编译样式文件
   * iview.css 是基础组件css
   * iview.pack.css 是套装的全部css
   * iview.all.css 是基础组件加套装的全部css
   * packages/*.css 是某个套装的css
   * article.css 是文章排版的css
   * */
  var gulp = require('gulp');
  var minifyCSS = require('gulp-minify-css');
  var less = require('gulp-less');
  var rename = require('gulp-rename');
  var concat = require('gulp-concat');
  
  // 组件的基础css
  gulp.task('base', function () {
       gulp.src('../styles/index.less')
           .pipe(less())
           .pipe(minifyCSS())
           .pipe(rename('iview.css'))
           .pipe(gulp.dest('../dist/styles'))
  });
  
  // 字体
  gulp.task('fonts', function () {
      gulp.src('../styles/common/iconfont/fonts/*.*')
          .pipe(gulp.dest('../dist/styles/fonts'))
  });
  
  // 文章排版
  gulp.task('article', function () {
      gulp.src('../styles/article/index.less')
          .pipe(less())
          .pipe(minifyCSS())
          .pipe(rename('article.css'))
          .pipe(gulp.dest('../dist/styles'))
  });
  
  // 套装的全部css
  gulp.task('pack-all', function () {
      gulp.src('../styles/package.less')
          .pipe(less())
          .pipe(minifyCSS())
          .pipe(rename('iview.pack.css'))
          .pipe(gulp.dest('../dist/styles'))
  });
  
  // 每个套装的css
  gulp.task('pack', function () {
      gulp.src(['../styles/packages/*.less', '!../styles/packages/index.less'])
          .pipe(less())
          .pipe(minifyCSS())
          .pipe(rename({
              prefix: 'iview.pack.'
          }))
          .pipe(gulp.dest('../dist/styles/packages'))
  });
  
  // 全部css(包含组件和套装)
  gulp.task('all', function () {
      gulp.src(['../styles/index.less', '../styles/package.less'])
          .pipe(less())
          .pipe(concat('iview.all.css'))
          .pipe(minifyCSS())
          .pipe(gulp.dest('../dist/styles'))
  });
  
  gulp.task('default', ['base', 'fonts', 'article', 'pack-all', 'pack', 'all']);