Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
陈峰
6 years ago
Commit
a7d9d75be05d855beccb8464c8a54deae05cdb33
2 parents
b3576898
4d3b8679
Merge branch 'feature/fixsw' into 'release/10.10'
fix sw See merge request
!1549
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
17 deletions
build/yo.node.conf.js
public/static/sw.js
yarn.lock
build/yo.node.conf.js
View file @
a7d9d75
...
...
@@ -2,7 +2,7 @@ const shelljs = require('shelljs');
const
yargs
=
require
(
'yargs'
);
const
path
=
require
(
'path'
);
const
cssnano
=
require
(
'cssnano'
);
const
r
equest
=
require
(
'request
'
);
const
r
p
=
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
=>
{
...
...
public/static/sw.js
View file @
a7d9d75
...
...
@@ -132,3 +132,4 @@ self.workbox.routing.registerRoute(args => {
})
]}).
handle
(
args
);
});
...
...
yarn.lock
View file @
a7d9d75
...
...
@@ -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"
...
...
Please
register
or
login
to post a comment