Esempio n. 1
0
 end: function () {
   processors.push(sprites(opts));
   vfs.src(cssFiles)
     .pipe(athenaMate.plumber())
     .pipe($.postcss(processors))
     .pipe(vfs.dest(path.join(modulePath, 'dist', '_static', 'css')))
     .on('end', function () {
       vfs.src(path.join(modulePath, 'dist', '_static', '**'), { base: path.join(modulePath, 'dist', '_static') })
         .pipe(athenaMate.replace({
           cwd: appPath,
           module: moduleConf.module,
           serve: true
         }))
         .pipe(vfs.dest(path.join(appPath, '.temp', appConf.app, moduleConf.module)))
         .on('end', function () {
           resolve();
         });
     })
     .on('error', function (err) {
       reject(err);
     });
 }
Esempio n. 2
0
 end: function () {
   var cssFiles = [];
   args.pageFiles.forEach(function (item) {
     var page = path.basename(item, path.extname(item));
     cssFiles.push(path.join(modulePath, 'dist', '_static', 'css', page + '.css'));
     cssFiles.push(path.join('!' + modulePath, 'dist', '_static', 'css', page + '.min.css'));
   });
   processors.push(sprites(opts));
   vfs.src(cssFiles)
     .pipe(athenaMate.plumber())
     .pipe($.postcss(processors))
     .pipe(athenaMate.replace({
       cwd: appPath,
       module: moduleConf.module,
       serve: true
     }))
     .pipe(vfs.dest(path.join(appPath, '.temp', appConf.app, moduleConf.module, 'css')))
     .on('end', function () {
       resolve();
     })
     .on('error', function (err) {
       reject(err);
     });
 }
Esempio n. 3
0
    return new Promise(function (resolve, reject) {
      var autoprefixer = require('autoprefixer');
      var vfs = require('vinyl-fs');
      var fs = require('fs');
      var path = require('path');
      var sprites = require('postcss-athena-spritesmith');
      var pxtorem = require('postcss-pxtorem');

      var athenaMate = require('../athena_mate');
      var Util = require('../../util');
      //是否开启px转rem
      var px2rem = moduleConf.support.px2rem;
      //是否开启雪碧图合并
      var csssprite = moduleConf.support.csssprite;

      var platform = appConf.platform ? appConf.platform : 'mobile';

      var autoprefixerConf = moduleConf.support.autoprefixer;
      var browsers = [];
      if (autoprefixerConf) {
        browsers = autoprefixerConf[platform];
      } else {
        browsers = ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1'];
      }

      var processors = [
        autoprefixer({browsers: browsers}),
      ];

      if( px2rem && px2rem.enable !== false ){
        processors.push(pxtorem({
          root_value: px2rem.root_value,
          unit_precision: px2rem.unit_precision,
          prop_white_list: px2rem.prop_white_list,
          selector_black_list: px2rem.selector_black_list,
          replace: px2rem.replace,
          media_query: px2rem.media_query
        }))
      }

      if( csssprite && csssprite.enable !== false ){
        var opts = {
          stylesheetPath: path.join(modulePath, 'dist', '_static', 'css'),
          spritePath: path.join(modulePath, 'dist', '_static', 'images', 'sprite.png'),
          retina: csssprite.retina || false,
          rootvalue: csssprite.rootvalue,
          padding: csssprite.padding
        }
      }

      $.util.log($.util.colors.green('开始' + mod + '模块任务styles!'));

      vfs.src([path.join(modulePath, 'dist', '_static', 'css', '*.css'), path.join('!' + modulePath, 'dist', '_static', 'css', '*.min.css')])
        .pipe(athenaMate.plumber())
        .pipe($.postcss(processors))
        .pipe(vfs.dest(path.join(modulePath, 'dist', '_static', 'css')))
        .pipe(
          $.postcss([
            sprites(opts)
          ])
        )
        .pipe(vfs.dest(path.join(modulePath, 'dist', '_static', 'css')))
        .on('end', function () {
          $.util.log($.util.colors.green('结束' + mod + '模块任务styles!'));
          resolve();
        })
        .on('error', function (err) {
          $.util.log($.util.colors.red(mod + '模块任务styles失败!'));
          reject(err);
        });
    });