G
G
Graff_us2021-06-07 16:55:57
gulp.js
Graff_us, 2021-06-07 16:55:57

Gulp fontsStyle mixins?

Can anyone help, related to connecting fonts through a mixin.
I want to make sure that when updating the gallp, there is a check that if something is written in the _fonts.scss file, then do not rewrite it, but leave it as it is.
and then always when I restart the galp, the include line is updated and erases what I changed in the include.

const cb = () => { };
let srcFonts = './src/scss/basic/_fonts.scss';
let appFonts = './app/fonts/';
const fontsStyle = (done) => {
   let file_content = fs.readFileSync(srcFonts);
   fs.writeFile(srcFonts, '', cb);
   fs.readdir(appFonts, function (err, items) {
      if (items) {
         let c_fontname;
         for (var i = 0; i < items.length; i++) {
            let fontname = items[i].split('.');
            fontname = fontname[0];
            if (c_fontname != fontname) {
               fs.appendFile(srcFonts, '@include font("' + fontname + '", "' + fontname + '", 400, "normal");\r\n', cb);
            }
            c_fontname = fontname;
         }
      }
   });
   done();

};

   watch('./src/fonts/**.ttf', fonts);
   watch('./src/fonts/**.ttf', fontsStyle);

exports.fontsStyle = fontsStyle;

exports.default = series(clean, parallel(htmlInclude, scripts, fonts, resources, imgToApp), fontsStyle, styles, watchFiles);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question