gulp-iconfont-css
gulp-iconfont-css copied to clipboard
targetPath creates subfolders with a full directory path
How can I resolve this problem ? The targetPath creates a subfolder inside the fonts folder that comprises the full working path inside the fonts director. For example: fonts/ Users/username/full project path/icons.scss.
The problem occurs in MacOs and Linux. I do not desire to have either additional folders created or _icons.scss.
@benifbond, please provide your complete gulp function as well as the versions of the relevant npm dependencies.
Thanks for your reply. Here is the requested function:
gulp.task('svg2font', function() {
const fontName = 'asknet';
const targetPath = path.join(process.env.INIT_CWD, 'skins', 'default', 'source', 'scss', 'icons.scss');
const filesMap = {};
glob.sync('node_modules/@myCompany/source-resources/images/icons/*/*.svg').forEach(file => {
filesMap[path.basename(file)] = file;
});
glob.sync('skins/default/source/images/icons/**/*.svg').forEach(file => {
filesMap[path.basename(file)] = file;
});
return gulp.src(Object.values(filesMap))
.pipe(iconfontCss({
fontName: fontName,
cssClass: 'anc-icon',
path: 'node_modules/@myCompany/source-resources/scss/component/icons/_template.tmpl',
targetPath: targetPath,
fontPath: '../fonts/'
}))
.pipe(iconfont({
fontName: fontName,
prependUnicode: false,
formats: ['ttf', 'eot', 'woff', 'woff2', 'svg'],
normalize: true,
fontHeight: 1024,
timestamp: Math.round(Date.now() / 1000) // recommended to get consistent builds when watching files
}))
.pipe(gulp.dest('dist/default/fonts/'));
});
Relevant npm packages:
{
"devDependencies": {
"glob": "^7.1.2",
"gulp": "^3.9.1",
"gulp-iconfont": "^9.0.2",
"gulp-iconfont-css": "^2.1.0",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.0",
"gulp-util": "^3.0.8",
"run-sequence": "^2.2.1",
"sassdoc": "^2.3.0",
"stylelint": "^8.4.0",
"stylelint-config-standard": "^18.0.0"
}
}
@benifbond, thanks, this helps! So targetPath needs to be relative to dist/default/fonts/ (see options.targetPath). Can you try to set targetPath to something like ../../../skins/default/source/scss/icons.scss?
@backflip Thank you so much! It really works. I genuinely appreciate your time and help. Your assistance has been invaluable. I'm grateful for your support.