Authored by runner

dist

... ... @@ -39,8 +39,10 @@
</div>
{{#if devEnv}}
<script src="//localhost:5001/libs.js"></script>
<script src="//localhost:5001/{{module}}.{{page}}.js"></script>
{{^}}
<script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/libs.js"></script>
<script src="//cdn.yoho.cn/m-yohobuy-node/{{version}}/{{module}}.{{page}}.js"></script>
{{/if}}
</body>
... ...
... ... @@ -32,8 +32,8 @@ exports.image = (url, width, height, mode) => {
* @param {[object]} options 上下文环境,一般不手动传
* @return {[boolen]}
*/
exports.ifEqualTo = (v1, v2, _options) => {
if (v1 === v2) {
exports.isEqual = (v1, v2, _options) => {
if (_.isEqual(v1, v2)) {
return _options.fn(this); // eslint-disable-line
}
... ...
... ... @@ -100,7 +100,6 @@ const postcssPlugin = (et) => {
require('postcss-sprites').default(sprites),
require('postcss-assets')(assets),
require('postcss-calc'),
require('postcss-opacity'),
require('postcss-pxtorem')({
rootValue: 40,
unitPrecision: 5, // 保留5位小数字
... ... @@ -201,15 +200,20 @@ gulp.task('webpack-dev-server', () => {
});
// webpack compile in pro
gulp.task('webpack', () => {
gulp.task('webpack', (done) => {
var proConfig = Object.assign({}, webpackConfig);
proConfig.output.path = dist.js;
proConfig.plugins = [new webpack.optimize.UglifyJsPlugin()];
proConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
webpack(proConfig, (err, stats) => {
if (err) {
throw new gutil.PluginError('webpack', err);
}
gutil.log('[webpack compile]:', stats.endTime - stats.startTime, 'ms');
done();
});
});
... ...
... ... @@ -6,7 +6,7 @@
'use strict';
// const webpack = require('webpack');
const webpack = require('webpack');
const path = require('path');
const _ = require('lodash');
... ... @@ -21,6 +21,16 @@ shelljs.ls(path.join(__dirname, 'js/**/*.page.js')).forEach((f) => {
// Important
// 生成规则:module.page: './js/module/xx.page.js'
entries[`${dir[0]}.${dir[1].match(/(.*).page.js/)[1]}`] = `./js/${dir.join('/')}`;
entries.libs = [
'yoho-jquery',
'yoho-fastclick',
'yoho-hammer',
'yoho-handlebars',
'yoho-iscroll',
'yoho-jquery-lazyload',
'yoho-mlellipsis',
'yoho-swiper'
];
});
module.exports = {
... ... @@ -28,5 +38,12 @@ module.exports = {
output: {
path: path.join(__dirname, 'bundle'), // absolute path
filename: '[name].js'
}
},
plugins: [
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'libs',
filename: 'libs.js'
})
]
};
... ...