...
|
...
|
@@ -39,9 +39,6 @@ const dist = { |
|
|
font: `${distRoot}/assets/font`
|
|
|
};
|
|
|
|
|
|
// webpack 内嵌的样式中的雪碧图,写文件的时候会有冲突,这边使用单实例
|
|
|
let postcssSprites;
|
|
|
|
|
|
/**
|
|
|
* postcss plugins for both dev and pro
|
|
|
* @parem et Symbol
|
...
|
...
|
@@ -96,12 +93,9 @@ const postcssPlugin = (et) => { |
|
|
});
|
|
|
}
|
|
|
|
|
|
if (!postcssSprites) {
|
|
|
postcssSprites = require('postcss-sprites').default(sprites);
|
|
|
}
|
|
|
plugins = [
|
|
|
require('precss'),
|
|
|
postcssSprites,
|
|
|
require('postcss-sprites').default(sprites),
|
|
|
require('postcss-assets')(assets),
|
|
|
require('postcss-calc'),
|
|
|
require('postcss-pxtorem')({
|
...
|
...
|
@@ -149,7 +143,9 @@ gulp.task('dist', ['ge'], () => { |
|
|
gulp.task('postcss-dev', () => {
|
|
|
return gulp.src('scss/index.css')
|
|
|
.pipe(sourcemaps.init())
|
|
|
.pipe(postcss(postcssPlugin(env.dev)))
|
|
|
.pipe(postcss(postcssPlugin(env.dev), {
|
|
|
parser: require('postcss-scss')
|
|
|
}))
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
.pipe(gulp.dest('css/'));
|
|
|
});
|
...
|
...
|
@@ -177,7 +173,9 @@ gulp.task('font', () => { |
|
|
// postcss compile in pro
|
|
|
gulp.task('postcss', ['assets'], () => {
|
|
|
return gulp.src('scss/index.css')
|
|
|
.pipe(postcss(postcssPlugin(env.pro)))
|
|
|
.pipe(postcss(postcssPlugin(env.pro), {
|
|
|
parser: require('postcss-scss')
|
|
|
}))
|
|
|
.pipe(cssnano({
|
|
|
safe: true
|
|
|
}))
|
...
|
...
|
@@ -189,7 +187,12 @@ gulp.task('webpack-dev-server', () => { |
|
|
const devConfig = Object.assign({}, webpackConfig, {
|
|
|
devtool: '#inline-source-map',
|
|
|
vue: {
|
|
|
postcss: postcssPlugin(env.dev),
|
|
|
postcss: {
|
|
|
plugins: postcssPlugin(env.dev),
|
|
|
options: {
|
|
|
parser: require('postcss-scss')
|
|
|
}
|
|
|
},
|
|
|
autoprefixer: false,
|
|
|
loaders: {
|
|
|
css: ExtractTextPlugin.extract(['css?-url'])
|
...
|
...
|
@@ -219,7 +222,12 @@ gulp.task('webpack-dev-server', () => { |
|
|
gulp.task('webpack', ['assets'], (done) => {
|
|
|
const proConfig = Object.assign({}, webpackConfig, {
|
|
|
vue: {
|
|
|
postcss: postcssPlugin(env.pro),
|
|
|
postcss: {
|
|
|
plugins: postcssPlugin(env.dev),
|
|
|
options: {
|
|
|
parser: require('postcss-scss')
|
|
|
}
|
|
|
},
|
|
|
autoprefixer: false,
|
|
|
loaders: {
|
|
|
css: ExtractTextPlugin.extract(['css?-url'])
|
...
|
...
|
|