Authored by ccbikai

构建脚本完善

@@ -13,14 +13,16 @@ const ftp = require('gulp-ftp'); @@ -13,14 +13,16 @@ const ftp = require('gulp-ftp');
13 const postcss = require('gulp-postcss'); 13 const postcss = require('gulp-postcss');
14 const sourcemaps = require('gulp-sourcemaps'); 14 const sourcemaps = require('gulp-sourcemaps');
15 const cssnano = require('gulp-cssnano'); 15 const cssnano = require('gulp-cssnano');
  16 +const scss = require('postcss-scss');
16 17
17 const webpack = require('webpack'); 18 const webpack = require('webpack');
18 const WebpackDevServer = require('webpack-dev-server'); 19 const WebpackDevServer = require('webpack-dev-server');
19 -const webpackConfig = require('./webpack.config.js');  
20 const ExtractTextPlugin = require('extract-text-webpack-plugin'); 20 const ExtractTextPlugin = require('extract-text-webpack-plugin');
21 const Dashboard = require('webpack-dashboard'); 21 const Dashboard = require('webpack-dashboard');
22 const DashboardPlugin = require('webpack-dashboard/plugin'); 22 const DashboardPlugin = require('webpack-dashboard/plugin');
23 23
  24 +const webpackConfig = require('./webpack.config.js');
  25 +
24 const env = { 26 const env = {
25 dev: Symbol('development'), 27 dev: Symbol('development'),
26 pro: Symbol('production') 28 pro: Symbol('production')
@@ -48,7 +50,7 @@ const dist = { @@ -48,7 +50,7 @@ const dist = {
48 const postcssPlugin = (et) => { 50 const postcssPlugin = (et) => {
49 let sprites = { 51 let sprites = {
50 spritesmith: { 52 spritesmith: {
51 - padding: 2 53 + padding: 8
52 }, 54 },
53 filterBy(file) { 55 filterBy(file) {
54 // base64 的图片没有 url 过滤掉 56 // base64 的图片没有 url 过滤掉
@@ -60,7 +62,7 @@ const postcssPlugin = (et) => { @@ -60,7 +62,7 @@ const postcssPlugin = (et) => {
60 groupBy(file) { 62 groupBy(file) {
61 let group = file.url.split('/')[1]; 63 let group = file.url.split('/')[1];
62 64
63 - group = group === '' ? 'yo' : group; 65 + group = group === '' ? 'yoho' : group;
64 66
65 file.retina = true; 67 file.retina = true;
66 68
@@ -193,7 +195,7 @@ gulp.task('webpack-dev-server', () => { @@ -193,7 +195,7 @@ gulp.task('webpack-dev-server', () => {
193 postcss: { 195 postcss: {
194 plugins: postcssPlugin(env.dev), 196 plugins: postcssPlugin(env.dev),
195 options: { 197 options: {
196 - parser: require('postcss-scss') 198 + parser: scss
197 } 199 }
198 }, 200 },
199 autoprefixer: false, 201 autoprefixer: false,
@@ -243,7 +245,7 @@ gulp.task('webpack', ['assets'], (done) => { @@ -243,7 +245,7 @@ gulp.task('webpack', ['assets'], (done) => {
243 postcss: { 245 postcss: {
244 plugins: postcssPlugin(env.pro), 246 plugins: postcssPlugin(env.pro),
245 options: { 247 options: {
246 - parser: require('postcss-scss') 248 + parser: scss
247 } 249 }
248 }, 250 },
249 autoprefixer: false, 251 autoprefixer: false,
@@ -255,13 +257,12 @@ gulp.task('webpack', ['assets'], (done) => { @@ -255,13 +257,12 @@ gulp.task('webpack', ['assets'], (done) => {
255 257
256 proConfig.output.path = dist.js; 258 proConfig.output.path = dist.js;
257 259
258 - // TODO: 生产环境加载的插件独立出来 260 + // 生产环境插件
259 proConfig.plugins.push(new webpack.DefinePlugin({ 261 proConfig.plugins.push(new webpack.DefinePlugin({
260 'process.env': { 262 'process.env': {
261 NODE_ENV: '"production"' 263 NODE_ENV: '"production"'
262 } 264 }
263 - }));  
264 - proConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({ 265 + }), new webpack.optimize.UglifyJsPlugin({
265 compress: { 266 compress: {
266 warnings: false 267 warnings: false
267 } 268 }