...
|
...
|
@@ -13,14 +13,16 @@ const ftp = require('gulp-ftp'); |
|
|
const postcss = require('gulp-postcss');
|
|
|
const sourcemaps = require('gulp-sourcemaps');
|
|
|
const cssnano = require('gulp-cssnano');
|
|
|
const scss = require('postcss-scss');
|
|
|
|
|
|
const webpack = require('webpack');
|
|
|
const WebpackDevServer = require('webpack-dev-server');
|
|
|
const webpackConfig = require('./webpack.config.js');
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
const Dashboard = require('webpack-dashboard');
|
|
|
const DashboardPlugin = require('webpack-dashboard/plugin');
|
|
|
|
|
|
const webpackConfig = require('./webpack.config.js');
|
|
|
|
|
|
const env = {
|
|
|
dev: Symbol('development'),
|
|
|
pro: Symbol('production')
|
...
|
...
|
@@ -48,7 +50,7 @@ const dist = { |
|
|
const postcssPlugin = (et) => {
|
|
|
let sprites = {
|
|
|
spritesmith: {
|
|
|
padding: 2
|
|
|
padding: 8
|
|
|
},
|
|
|
filterBy(file) {
|
|
|
// base64 的图片没有 url 过滤掉
|
...
|
...
|
@@ -60,7 +62,7 @@ const postcssPlugin = (et) => { |
|
|
groupBy(file) {
|
|
|
let group = file.url.split('/')[1];
|
|
|
|
|
|
group = group === '' ? 'yo' : group;
|
|
|
group = group === '' ? 'yoho' : group;
|
|
|
|
|
|
file.retina = true;
|
|
|
|
...
|
...
|
@@ -193,12 +195,12 @@ gulp.task('webpack-dev-server', () => { |
|
|
postcss: {
|
|
|
plugins: postcssPlugin(env.dev),
|
|
|
options: {
|
|
|
parser: require('postcss-scss')
|
|
|
parser: scss
|
|
|
}
|
|
|
},
|
|
|
autoprefixer: false,
|
|
|
loaders: {
|
|
|
css: ExtractTextPlugin.extract(['css?-url'])
|
|
|
css: ExtractTextPlugin.extract(['css?-url&sourceMap'])
|
|
|
}
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -243,7 +245,7 @@ gulp.task('webpack', ['assets'], (done) => { |
|
|
postcss: {
|
|
|
plugins: postcssPlugin(env.pro),
|
|
|
options: {
|
|
|
parser: require('postcss-scss')
|
|
|
parser: scss
|
|
|
}
|
|
|
},
|
|
|
autoprefixer: false,
|
...
|
...
|
@@ -255,13 +257,12 @@ gulp.task('webpack', ['assets'], (done) => { |
|
|
|
|
|
proConfig.output.path = dist.js;
|
|
|
|
|
|
// TODO: 生产环境加载的插件独立出来
|
|
|
// 生产环境插件
|
|
|
proConfig.plugins.push(new webpack.DefinePlugin({
|
|
|
'process.env': {
|
|
|
NODE_ENV: '"production"'
|
|
|
}
|
|
|
}));
|
|
|
proConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
|
|
|
}), new webpack.optimize.UglifyJsPlugin({
|
|
|
compress: {
|
|
|
warnings: false
|
|
|
}
|
...
|
...
|
|