Authored by 陈峰

Merge branch 'feature/fixsw' into 'release/10.10'

fix sw



See merge request !1549
... ... @@ -2,7 +2,7 @@ const shelljs = require('shelljs');
const yargs = require('yargs');
const path = require('path');
const cssnano = require('cssnano');
const request = require('request');
const rp = require('request-promise');
const fs = require('fs');
const pkg = require('../package.json');
... ... @@ -33,19 +33,30 @@ new Promise((resolve, reject) => { // 加载manifest.json文件
cpPaths.push(`dist/statics/yohobuywap-node/${pkg.version}/manifest.json`);
resolve();
} else {
request({
url: `https://cdn.yoho.cn/yohobuywap-node/${pkg.version}/manifest.json`,
gzip: true,
json: true
}, (error, response, data) => {
if (error || !data || data.error) {
return reject(`download manifest.json faild:${error || !data || data.error}`);
return Promise.all([
rp({
url: `https://cdn.yoho.cn/yohobuywap-node/${pkg.version}/manifest.json`,
gzip: true,
json: true
}),
rp({
url: 'https://m.yohobuy.com/sw.js',
gzip: true
}),
]).then(results => {
const [manifest, sw] = results;
if (!manifest || !sw) {
throw 'manifest.json or sw.js download faild';
}
fs.writeFileSync(path.join(distDir, 'manifest.json'), JSON.stringify(data), {
fs.writeFileSync(path.join(distDir, 'manifest.json'), JSON.stringify(manifest), {
flag: 'w'
});
fs.writeFileSync(path.join(__dirname, '../public/static/sw.js'), sw, {
flag: 'w'
});
resolve();
});
}).catch(reject);
}
}).then(() => { // 拷贝node代码
cpPaths.forEach(p => {
... ...
... ... @@ -132,3 +132,4 @@ self.workbox.routing.registerRoute(args => {
})
]}).handle(args);
});
... ...
... ... @@ -4778,9 +4778,9 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"
influx-batch-sender@^0.1.6:
version "0.1.6"
resolved "http://npm.yohops.com/influx-batch-sender/-/influx-batch-sender-0.1.6.tgz#fe4fb11ac80ece3ca791e40c8de098ce0181d499"
influx-batch-sender@^0.1.7:
version "0.1.7"
resolved "http://npm.yohops.com/influx-batch-sender/-/influx-batch-sender-0.1.7.tgz#9f925bfc500e886cae27001b3cc20f2584fa464a"
dependencies:
debug "^3.0.1"
lodash "^4.17.4"
... ... @@ -11102,13 +11102,13 @@ yoho-md5@^2.0.0:
version "2.1.0"
resolved "http://npm.yohops.com/yoho-md5/-/yoho-md5-2.1.0.tgz#f0c00d343f775e77952ebce0826863ac52e0ad50"
yoho-node-lib@=0.6.32:
version "0.6.32"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.32.tgz#285b9c89445ed3e6aed9e2cdd4efb7637652a375"
yoho-node-lib@=0.6.33:
version "0.6.33"
resolved "http://npm.yohops.com/yoho-node-lib/-/yoho-node-lib-0.6.33.tgz#fca4dadedb80438d30d06fbb386d09912a4f9ca6"
dependencies:
dnscache "^1.0.1"
handlebars "^4.0.5"
influx-batch-sender "^0.1.6"
influx-batch-sender "^0.1.7"
lodash "^4.13.1"
lru-cache "^4.1.1"
md5 "^2.1.0"
... ...