refactor(extract-js): more stable at first download of Luciole

feat/test-less-compiled
dufraissejeremy 2 years ago
parent 7e0717491f
commit 1d0aa5ac9e
  1. 111
      js/extract-files-from-node-modules.js

@ -116,6 +116,62 @@ const http = require('http');
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)
if (!fs.existsSync(currentPath)) {
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 zip = new AdmZip(zipPath)
zip.extractAllTo(/*target path*/ currentPath, /*overwrite*/ true)
importLucioleFont()
},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
// mergeFilesSync(

Loading…
Cancel
Save