Authored by 毕凯

完善H5 gulp

{{#content}}
{{log this}}
{{! 头部banner}}
{{#bannerTop}}
{{> channel/banner-top}}
... ...
... ... @@ -51,6 +51,7 @@
"postcss-crip": "^2.0.0",
"postcss-opacity": "^3.0.0",
"postcss-position": "^0.4.0",
"postcss-pxtorem": "^3.3.1",
"postcss-short": "^1.4.0",
"postcss-sprites": "^3.1.2",
"postcss-use": "^2.0.2",
... ...
... ... @@ -15,7 +15,7 @@ const sourcemaps = require('gulp-sourcemaps');
const cssnano = require('gulp-cssnano');
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const WebpackDevServer = require('webpack-dev-server');
const webpackConfig = require('./webpack.config.js');
const env = {
... ... @@ -52,6 +52,8 @@ const postcssPlugin = (et) => {
group = group === '' ? 'yo' : group;
file.retina = true;
return group ? Promise.resolve(group) : Promise.reject(group);
}
},
... ... @@ -91,6 +93,13 @@ const postcssPlugin = (et) => {
require('postcss-assets')(assets),
require('postcss-calc'),
require('postcss-opacity'),
require('postcss-pxtorem')({
rootValue: 40,
unitPrecision: 5, // 保留5位小数字
minPixelValue: 2, // 小于 2 时,不转换
selectorBlackList: [], // 选择器黑名单,可以使用正则
propWhiteList: [] // 属性名称为空,表示替换所有属性的值
}),
// 可选
require('postcss-use')({
... ... @@ -165,7 +174,7 @@ gulp.task('webpack-dev-server', () => {
debug: true
});
new webpackDevServer(webpack(devConfig), {
new WebpackDevServer(webpack(devConfig), {
contentBase: '.',
publicPath: '//localhost:8000/',
hot: true,
... ... @@ -185,7 +194,7 @@ gulp.task('webpack', () => {
var proConfig = Object.assign({}, webpackConfig);
proConfig.output.path = dist.js;
webpack(proConfig, (err, stats) => {
webpack(proConfig, (err) => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
... ...