vite-plugin-fonts
Advanced tools
Comparing version
@@ -0,19 +1,6 @@ | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getOwnPropSymbols = Object.getOwnPropertySymbols; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __propIsEnum = Object.prototype.propertyIsEnumerable; | ||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; | ||
var __spreadValues = (a, b) => { | ||
for (var prop in b || (b = {})) | ||
if (__hasOwnProp.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
if (__getOwnPropSymbols) | ||
for (var prop of __getOwnPropSymbols(b)) { | ||
if (__propIsEnum.call(b, prop)) | ||
__defNormalProp(a, prop, b[prop]); | ||
} | ||
return a; | ||
}; | ||
var __export = (target, all) => { | ||
@@ -184,4 +171,2 @@ for (var name in all) | ||
return 600; | ||
if (weightOrSrc.includes("bold")) | ||
return 700; | ||
if (weightOrSrc.includes("extrabold")) | ||
@@ -191,2 +176,4 @@ return 800; | ||
return 800; | ||
if (weightOrSrc.includes("bold")) | ||
return 700; | ||
if (weightOrSrc.includes("black")) | ||
@@ -215,2 +202,4 @@ return 900; | ||
format = "truetype"; | ||
if (format === "otf") | ||
format = "opentype"; | ||
return `url('${url}') format('${format}')`; | ||
@@ -249,3 +238,3 @@ }).join(",\n "); | ||
if (!Array.isArray(families)) { | ||
families = Object.entries(families).map(([name, family]) => Array.isArray(family) || typeof family === "string" ? { name, src: family } : __spreadValues({ name }, family)); | ||
families = Object.entries(families).map(([name, family]) => Array.isArray(family) || typeof family === "string" ? { name, src: family } : { name, ...family }); | ||
} | ||
@@ -255,6 +244,6 @@ for (const { name, src, local } of families) { | ||
(Array.isArray(src) ? src : [src]).flatMap((x) => (0, import_fast_glob.sync)(x, { absolute: true, cwd: config2.root, onlyFiles: true })).filter(Boolean).forEach((src2) => { | ||
var _a, _b; | ||
var _a; | ||
const srcNoExt = (_a = src2.match(/(.*)\.(\w|\d)+$/)) == null ? void 0 : _a[1].toLowerCase(); | ||
if (srcNoExt) | ||
facesGrouped[srcNoExt] = ((_b = facesGrouped[srcNoExt]) != null ? _b : []).concat(src2); | ||
facesGrouped[srcNoExt] = (facesGrouped[srcNoExt] ?? []).concat(src2); | ||
}); | ||
@@ -261,0 +250,0 @@ const faces = Object.entries(facesGrouped).map(([srcNoExt, src2]) => ({ |
{ | ||
"name": "vite-plugin-fonts", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Webfont loader for vite", | ||
"author": "stafyniaksacha", | ||
"license": "MIT", | ||
"author": "stafyniaksacha", | ||
"repository": "stafyniaksacha/vite-plugin-fonts", | ||
@@ -20,4 +20,4 @@ "main": "dist/index.js", | ||
"build": "tsup src/index.ts --dts --format cjs,esm", | ||
"lint": "eslint --ext .ts ./src", | ||
"lint:fix": "eslint --fix --ext .ts ./src" | ||
"lint": "eslint .", | ||
"lint:fix": "eslint --fix ." | ||
}, | ||
@@ -31,10 +31,10 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"@antfu/eslint-config-ts": "^0.18.8", | ||
"@typescript-eslint/eslint-plugin": "^5.15.0", | ||
"eslint": "^8.11.0", | ||
"@antfu/eslint-config-ts": "^0.25.1", | ||
"@typescript-eslint/eslint-plugin": "^5.29.0", | ||
"eslint": "^8.18.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"tsup": "^5.12.1", | ||
"typescript": "^4.6.2", | ||
"vite": "^2.8.6" | ||
"tsup": "^6.1.2", | ||
"typescript": "^4.7.4", | ||
"vite": "^2.9.12" | ||
} | ||
} |
@@ -15,7 +15,7 @@ # vite-plugin-fonts | ||
// vite.config.js | ||
import ViteFonts from 'vite-plugin-fonts' | ||
import { VitePluginFonts } from 'vite-plugin-fonts' | ||
export default { | ||
plugins: [ | ||
ViteFonts({ | ||
VitePluginFonts({ | ||
google: { | ||
@@ -40,7 +40,7 @@ families: ['Source Sans Pro'], | ||
// vite.config.js | ||
import ViteFonts from 'vite-plugin-fonts' | ||
import { VitePluginFonts } from 'vite-plugin-fonts' | ||
export default { | ||
plugins: [ | ||
ViteFonts({ | ||
VitePluginFonts({ | ||
// Typekit API | ||
@@ -164,2 +164,2 @@ typekit: { | ||
- https://csswizardry.com/2020/05/the-fastest-google-fonts/ | ||
- _(unmaintained)_ https://www.npmjs.com/package/webfontloader | ||
- _(unmaintained)_ https://www.npmjs.com/package/webfontloader |
Sorry, the diff of this file is not supported yet
163
0.62%25007
-4.63%666
-3.48%