...
|
...
|
@@ -6,13 +6,17 @@ |
|
|
|
|
|
'use strict';
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
|
const gulp = require('gulp');
|
|
|
const _ = require('lodash');
|
|
|
const gutil = require('gulp-util');
|
|
|
const ftp = require('gulp-ftp');
|
|
|
|
|
|
const postcss = require('gulp-postcss');
|
|
|
const sourcemaps = require('gulp-sourcemaps');
|
|
|
const cssnano = require('gulp-cssnano');
|
|
|
const rename = require('gulp-rename');
|
|
|
|
|
|
const webpack = require('webpack');
|
|
|
const WebpackDevServer = require('webpack-dev-server');
|
...
|
...
|
@@ -48,9 +52,8 @@ const postcssPlugin = (et) => { |
|
|
padding: 2
|
|
|
},
|
|
|
groupBy(file) {
|
|
|
var group = file.url.split('/')[1];
|
|
|
|
|
|
group = group === '' ? 'yo' : group;
|
|
|
var dir = _.last(path.parse(file.styleFilePath).dir.split(path.sep));
|
|
|
var group = dir === 'scss' ? path.basename(file.styleFilePath, '.css') : dir;
|
|
|
|
|
|
return group ? Promise.resolve(group) : Promise.reject(group);
|
|
|
}
|
...
|
...
|
@@ -125,13 +128,21 @@ gulp.task('dist', ['ge'], () => { |
|
|
|
|
|
// postcss compile in dev
|
|
|
gulp.task('postcss-dev', () => {
|
|
|
return gulp.src(['scss/index.css', 'scss/cart.index.css'])
|
|
|
return gulp.src(['scss/base.css', 'scss/*/_index.css', '!scss/plugin/*', '!scss/common/*'])
|
|
|
.pipe(sourcemaps.init())
|
|
|
.pipe(postcss(postcssPlugin(env.dev)))
|
|
|
.on('error', function(err) {
|
|
|
gutil.log(err);
|
|
|
this.emit('end');
|
|
|
})
|
|
|
.pipe(rename((cssPath) => {
|
|
|
if (cssPath.dirname === '.') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
cssPath.basename = `${cssPath.dirname}`;
|
|
|
cssPath.dirname = './';
|
|
|
}))
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
.pipe(gulp.dest('css/'));
|
|
|
});
|
...
|
...
|
@@ -158,9 +169,17 @@ gulp.task('font', () => { |
|
|
|
|
|
// postcss compile in pro
|
|
|
gulp.task('postcss', ['assets'], () => {
|
|
|
return gulp.src(['scss/index.css', 'scss/cart.index.css'])
|
|
|
return gulp.src(['scss/base.css', 'scss/*/_index.css', '!scss/plugin/*', '!scss/common/*'])
|
|
|
.pipe(postcss(postcssPlugin(env.pro)))
|
|
|
.pipe(cssnano())
|
|
|
.pipe(rename((cssPath) => {
|
|
|
if (cssPath.dirname === '.') {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
cssPath.basename = `${cssPath.dirname}`;
|
|
|
cssPath.dirname = './';
|
|
|
}))
|
|
|
.pipe(gulp.dest(dist.css));
|
|
|
});
|
|
|
|
...
|
...
|
|