Authored by htoooth

fix css

... ... @@ -16,12 +16,12 @@
{{/dnsPrefetch.hosts}}
{{#if devEnv}}
<link rel="stylesheet" href="//{{devHost}}:5002/css/index.css">
<link rel="stylesheet" href="//{{devHost}}:5002/css/cart.index.css">
<link rel="stylesheet" href="//{{devHost}}:5002/css/base.css">
<link rel="stylesheet" href="//{{devHost}}:5002/css/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}">
{{^}}
<link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/index.css">
<link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/cart.index.css">
<link rel="stylesheet" href="//{{#isEqual cdn 'qcloud'}}qcdn.yoho.cn{{^}}cdn.yoho.cn{{/isEqual}}/yohobuy-node/{{version}}/{{#if cssModule}}{{cssModule}}.css{{^}}{{module}}.css{{/if}}">
{{/if}}
</head>
<body>
... ...
... ... @@ -78,6 +78,7 @@
"gulp-cssnano": "^2.1.2",
"gulp-ftp": "^1.1.0",
"gulp-postcss": "^6.1.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-util": "^3.0.7",
"handlebars-loader": "^1.4.0",
... ...
... ... @@ -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));
});
... ...
@import "../channel/index"
... ...
... ... @@ -6,15 +6,5 @@
@import "common/dialog";
@import "pager";
@import "path-nav";
/* 模块 */
@import 'help/index';
@import "channel/index";
@import "product/index";
@import "passport/index";
@import "share";
@import 'home/index';
@import 'guang/index';
/*@import 'cart/index';*/
@import 'service/index';
@import '3party/index';
... ...
@import "../channel/index"
... ...
@charset "utf-8";
/* 模块 */
@import 'cart/index';