Showing
1 changed file
with
35 additions
and
30 deletions
@@ -50,30 +50,30 @@ const dist = { | @@ -50,30 +50,30 @@ const dist = { | ||
50 | */ | 50 | */ |
51 | const postcssPlugin = (et) => { | 51 | const postcssPlugin = (et) => { |
52 | let sprites = { | 52 | let sprites = { |
53 | - spritesmith: { | ||
54 | - padding: 8 | ||
55 | - }, | ||
56 | - filterBy(file) { | ||
57 | - // base64 的图片没有 url 过滤掉 | ||
58 | - if (file.url) { | ||
59 | - return Promise.resolve(); | ||
60 | - } | ||
61 | - return Promise.reject(); | ||
62 | - }, | ||
63 | - groupBy(file) { | ||
64 | - let group = file.url.split('/')[1]; | ||
65 | - let entry = path.basename(file.styleFilePath); | ||
66 | - | ||
67 | - file.retina = true; | ||
68 | - file.radio = 2; | 53 | + spritesmith: { |
54 | + padding: 8 | ||
55 | + }, | ||
56 | + filterBy(file) { | ||
57 | + // base64 的图片没有 url 过滤掉 | ||
58 | + if (file.url) { | ||
59 | + return Promise.resolve(); | ||
60 | + } | ||
61 | + return Promise.reject(); | ||
62 | + }, | ||
63 | + groupBy(file) { | ||
64 | + let group = file.url.split('/')[1]; | ||
65 | + let entry = path.basename(file.styleFilePath); | ||
69 | 66 | ||
70 | - if (group) { | ||
71 | - group = entry + '.' + group; | ||
72 | - } | 67 | + file.retina = true; |
68 | + file.radio = 2; | ||
73 | 69 | ||
74 | - return group ? Promise.resolve(group) : Promise.reject('yoho'); | 70 | + if (group) { |
71 | + group = entry + '.' + group; | ||
75 | } | 72 | } |
76 | - }, | 73 | + |
74 | + return group ? Promise.resolve(group) : Promise.reject('yoho'); | ||
75 | + } | ||
76 | + }, | ||
77 | assets, | 77 | assets, |
78 | plugins; | 78 | plugins; |
79 | 79 | ||
@@ -228,8 +228,10 @@ gulp.task('webpack-dev-server', () => { | @@ -228,8 +228,10 @@ gulp.task('webpack-dev-server', () => { | ||
228 | devConfig.output.publicPath = 'http://localhost:5001/'; | 228 | devConfig.output.publicPath = 'http://localhost:5001/'; |
229 | 229 | ||
230 | // 开发环境插件 | 230 | // 开发环境插件 |
231 | - devConfig.plugins[0] = new ExtractTextPlugin('bundle/[name].css'); | ||
232 | - devConfig.plugins.push(new webpack.HotModuleReplacementPlugin()); | 231 | + devConfig.plugins.push( |
232 | + new ExtractTextPlugin('bundle/[name].css'), | ||
233 | + new webpack.HotModuleReplacementPlugin() | ||
234 | + ); | ||
233 | 235 | ||
234 | devConfig.entry.libs.unshift(`webpack-dev-server/client?${devConfig.output.publicPath}`, 'webpack/hot/dev-server'); | 236 | devConfig.entry.libs.unshift(`webpack-dev-server/client?${devConfig.output.publicPath}`, 'webpack/hot/dev-server'); |
235 | 237 | ||
@@ -281,13 +283,16 @@ gulp.task('webpack', ['assets'], (done) => { | @@ -281,13 +283,16 @@ gulp.task('webpack', ['assets'], (done) => { | ||
281 | proConfig.output.path = dist.js; | 283 | proConfig.output.path = dist.js; |
282 | 284 | ||
283 | // 生产环境插件 | 285 | // 生产环境插件 |
284 | - proConfig.plugins.push(new webpack.DefinePlugin({ | ||
285 | - 'process.env': { | ||
286 | - NODE_ENV: '"production"' | ||
287 | - } | ||
288 | - }), new UglifyJsParallelPlugin({ | ||
289 | - workers: os.cpus().length | ||
290 | - })); | 286 | + proConfig.plugins.push( |
287 | + new webpack.DefinePlugin({ | ||
288 | + 'process.env': { | ||
289 | + NODE_ENV: '"production"' | ||
290 | + } | ||
291 | + }), | ||
292 | + new UglifyJsParallelPlugin({ | ||
293 | + workers: os.cpus().length | ||
294 | + }) | ||
295 | + ); | ||
291 | 296 | ||
292 | webpack(proConfig, (err, stats) => { | 297 | webpack(proConfig, (err, stats) => { |
293 | if (err) { | 298 | if (err) { |
-
Please register or login to post a comment