refactor(extract-js): more stable at first download of Luciole
This commit is contained in:
parent
7e0717491f
commit
1d0aa5ac9e
@ -116,6 +116,62 @@ const http = require('http');
|
|||||||
|
|
||||||
|
|
||||||
let src = 'node_modules/Luciole/'
|
let src = 'node_modules/Luciole/'
|
||||||
|
const importLucioleFont = () => {
|
||||||
|
copySync(
|
||||||
|
'node_modules/Luciole/Luciole_webfonts/Read Me.txt',
|
||||||
|
'fonts/vendor/Luciole/Read Me.txt',
|
||||||
|
{ overwrite: true }
|
||||||
|
)
|
||||||
|
var arr = [
|
||||||
|
{
|
||||||
|
name:'Luciole-Regular',
|
||||||
|
style:'normal',
|
||||||
|
weight:'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'Luciole-Italic',
|
||||||
|
style:'italic',
|
||||||
|
weight:'normal'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'Luciole-Bold',
|
||||||
|
style:'normal',
|
||||||
|
weight:'bold'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name:'Luciole-BoldItalic',
|
||||||
|
style:'italic',
|
||||||
|
weight:'bold'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
let css = "/* Webfont: Luciole */\n\n"
|
||||||
|
arr.forEach((data)=>{
|
||||||
|
let name = data.name
|
||||||
|
copySync(
|
||||||
|
`node_modules/Luciole/Luciole_webfonts/${name}/${name}.woff`,
|
||||||
|
`fonts/vendor/Luciole/${name}/${name}.woff`,
|
||||||
|
{ overwrite: true }
|
||||||
|
)
|
||||||
|
css +=
|
||||||
|
`/* Webfont: ${name} */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Luciole';
|
||||||
|
src: url('./${name}/${name}.woff') format('woff');
|
||||||
|
font-style: ${data.style};
|
||||||
|
font-weight: ${data.weight};
|
||||||
|
text-rendering: optimizeLegibility;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
})
|
||||||
|
fs.writeFileSync(
|
||||||
|
path.join(
|
||||||
|
basePath,
|
||||||
|
'fonts/vendor/Luciole/Luciole.css'
|
||||||
|
),
|
||||||
|
css
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
let currentPath = path.join(basePath, src)
|
let currentPath = path.join(basePath, src)
|
||||||
if (!fs.existsSync(currentPath)) {
|
if (!fs.existsSync(currentPath)) {
|
||||||
fs.mkdirSync(currentPath,{recursive :true})
|
fs.mkdirSync(currentPath,{recursive :true})
|
||||||
@ -129,64 +185,11 @@ const request = http.get("http://www.luciole-vision.com/Fichiers/Luciole_webfont
|
|||||||
var AdmZip = require("adm-zip")
|
var AdmZip = require("adm-zip")
|
||||||
var zip = new AdmZip(zipPath)
|
var zip = new AdmZip(zipPath)
|
||||||
zip.extractAllTo(/*target path*/ currentPath, /*overwrite*/ true)
|
zip.extractAllTo(/*target path*/ currentPath, /*overwrite*/ true)
|
||||||
|
importLucioleFont()
|
||||||
},500)
|
},500)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
copySync(
|
|
||||||
'node_modules/Luciole/Luciole_webfonts/Read Me.txt',
|
|
||||||
'fonts/vendor/Luciole/Read Me.txt',
|
|
||||||
{ overwrite: true }
|
|
||||||
)
|
|
||||||
var arr = [
|
|
||||||
{
|
|
||||||
name:'Luciole-Regular',
|
|
||||||
style:'normal',
|
|
||||||
weight:'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'Luciole-Italic',
|
|
||||||
style:'italic',
|
|
||||||
weight:'normal'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'Luciole-Bold',
|
|
||||||
style:'normal',
|
|
||||||
weight:'bold'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name:'Luciole-BoldItalic',
|
|
||||||
style:'italic',
|
|
||||||
weight:'bold'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
let css = "/* Webfont: Luciole */\n\n"
|
|
||||||
arr.forEach((data)=>{
|
|
||||||
let name = data.name
|
|
||||||
copySync(
|
|
||||||
`node_modules/Luciole/Luciole_webfonts/${name}/${name}.woff`,
|
|
||||||
`fonts/vendor/Luciole/${name}/${name}.woff`,
|
|
||||||
{ overwrite: true }
|
|
||||||
)
|
|
||||||
css +=
|
|
||||||
`/* Webfont: ${name} */
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Luciole';
|
|
||||||
src: url('./${name}/${name}.woff') format('woff');
|
|
||||||
font-style: ${data.style};
|
|
||||||
font-weight: ${data.weight};
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
}
|
|
||||||
`
|
|
||||||
})
|
|
||||||
fs.writeFileSync(
|
|
||||||
path.join(
|
|
||||||
basePath,
|
|
||||||
'fonts/vendor/Luciole/Luciole.css'
|
|
||||||
),
|
|
||||||
css
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
// example
|
// example
|
||||||
// mergeFilesSync(
|
// mergeFilesSync(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user