Authored by runner

dist

@@ -39,8 +39,10 @@ @@ -39,8 +39,10 @@
39 </div> 39 </div>
40 40
41 {{#if devEnv}} 41 {{#if devEnv}}
  42 + <script src="//localhost:5001/libs.js"></script>
42 <script src="//localhost:5001/{{module}}.{{page}}.js"></script> 43 <script src="//localhost:5001/{{module}}.{{page}}.js"></script>
43 {{^}} 44 {{^}}
  45 + <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js"></script>
44 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script> 46 <script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
45 {{/if}} 47 {{/if}}
46 </body> 48 </body>
@@ -32,8 +32,8 @@ exports.image = (url, width, height, mode) => { @@ -32,8 +32,8 @@ exports.image = (url, width, height, mode) => {
32 * @param {[object]} options 上下文环境,一般不手动传 32 * @param {[object]} options 上下文环境,一般不手动传
33 * @return {[boolen]} 33 * @return {[boolen]}
34 */ 34 */
35 -exports.ifEqualTo = (v1, v2, _options) => {  
36 - if (v1 === v2) { 35 +exports.isEqual = (v1, v2, _options) => {
  36 + if (_.isEqual(v1, v2)) {
37 return _options.fn(this); // eslint-disable-line 37 return _options.fn(this); // eslint-disable-line
38 } 38 }
39 39
@@ -100,7 +100,6 @@ const postcssPlugin = (et) => { @@ -100,7 +100,6 @@ const postcssPlugin = (et) => {
100 require('postcss-sprites').default(sprites), 100 require('postcss-sprites').default(sprites),
101 require('postcss-assets')(assets), 101 require('postcss-assets')(assets),
102 require('postcss-calc'), 102 require('postcss-calc'),
103 - require('postcss-opacity'),  
104 require('postcss-pxtorem')({ 103 require('postcss-pxtorem')({
105 rootValue: 40, 104 rootValue: 40,
106 unitPrecision: 5, // 保留5位小数字 105 unitPrecision: 5, // 保留5位小数字
@@ -201,15 +200,20 @@ gulp.task('webpack-dev-server', () => { @@ -201,15 +200,20 @@ gulp.task('webpack-dev-server', () => {
201 }); 200 });
202 201
203 // webpack compile in pro 202 // webpack compile in pro
204 -gulp.task('webpack', () => { 203 +gulp.task('webpack', (done) => {
205 var proConfig = Object.assign({}, webpackConfig); 204 var proConfig = Object.assign({}, webpackConfig);
206 205
207 proConfig.output.path = dist.js; 206 proConfig.output.path = dist.js;
208 - proConfig.plugins = [new webpack.optimize.UglifyJsPlugin()]; 207 + proConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
  208 + compress: {
  209 + warnings: false
  210 + }
  211 + }));
209 webpack(proConfig, (err, stats) => { 212 webpack(proConfig, (err, stats) => {
210 if (err) { 213 if (err) {
211 throw new gutil.PluginError('webpack', err); 214 throw new gutil.PluginError('webpack', err);
212 } 215 }
213 gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms'); 216 gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms');
  217 + done();
214 }); 218 });
215 }); 219 });
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -// const webpack = require('webpack'); 9 +const webpack = require('webpack');
10 const path = require('path'); 10 const path = require('path');
11 const _ = require('lodash'); 11 const _ = require('lodash');
12 12
@@ -21,6 +21,16 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => { @@ -21,6 +21,16 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => {
21 // Important 21 // Important
22 // 生成规则:module.page: './js/module/xx.page.js' 22 // 生成规则:module.page: './js/module/xx.page.js'
23 entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = `./js/${dir.join('/')}`; 23 entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = `./js/${dir.join('/')}`;
  24 + entries.libs = [
  25 + 'yoho-jquery',
  26 + 'yoho-fastclick',
  27 + 'yoho-hammer',
  28 + 'yoho-handlebars',
  29 + 'yoho-iscroll',
  30 + 'yoho-jquery-lazyload',
  31 + 'yoho-mlellipsis',
  32 + 'yoho-swiper'
  33 + ];
24 }); 34 });
25 35
26 module.exports = { 36 module.exports = {
@@ -28,5 +38,12 @@ module.exports = { @@ -28,5 +38,12 @@ module.exports = {
28 output: { 38 output: {
29 path: path.join(__dirname, 'bundle'), // absolute path 39 path: path.join(__dirname, 'bundle'), // absolute path
30 filename: '[name].js' 40 filename: '[name].js'
31 - } 41 + },
  42 + plugins: [
  43 + new webpack.optimize.OccurenceOrderPlugin(),
  44 + new webpack.optimize.CommonsChunkPlugin({
  45 + name: 'libs',
  46 + filename: 'libs.js'
  47 + })
  48 + ]
32 }; 49 };