fix: remove unused stuff

This commit is contained in:
max_richter 2021-12-18 14:41:55 +01:00
parent 6d0af46768
commit 92bbab057c
10 changed files with 0 additions and 510 deletions

21
node_modules/.modules.yaml generated vendored
View File

@ -1,21 +0,0 @@
hoistPattern:
- '*'
hoistedDependencies: {}
included:
dependencies: true
devDependencies: true
optionalDependencies: true
layoutVersion: 5
packageManager: pnpm@6.22.2
pendingBuilds: []
prunedAt: Wed, 17 Nov 2021 13:45:43 GMT
publicHoistPattern:
- '*types*'
- '*eslint*'
- '@prettier/plugin-*'
- '*prettier-plugin-*'
registries:
default: https://registry.npmjs.org/
skipped: []
storeDir: /home/jim/.pnpm-store/v3
virtualStoreDir: .pnpm

15
node_modules/.pnpm/lock.yaml generated vendored
View File

@ -1,15 +0,0 @@
lockfileVersion: 5.3
specifiers:
vite-plugin-fonts: ^0.2.2
devDependencies:
vite-plugin-fonts: 0.2.2
packages:
/vite-plugin-fonts/0.2.2:
resolution: {integrity: sha512-fhzhsrTiuzlDjSO6g5sV5EVIIvbb8lmsaIY6eUTBM4lcF55x40UBpHrcyvNwIhQG211g0lu83XC7oZlkmvdkMA==}
peerDependencies:
vite: ^2.0.0
dev: true

View File

@ -1,113 +0,0 @@
# vite-plugin-fonts
Webfont loader for vite
### Install
```sh
npm i --save-dev vite-plugin-fonts # yarn add -D vite-plugin-fonts
```
### Add it to vite.config.js
```ts
// vite.config.js
import ViteFonts from 'vite-plugin-fonts'
export default {
plugins: [
ViteFonts({
google: {
families: ['Source Sans Pro']
},
})
],
}
```
## Options
```ts
// vite.config.js
import ViteFonts from 'vite-plugin-fonts'
export default {
plugins: [
ViteFonts({
// Typekit API
typekit: {
/**
* Typekit project id
*/
id: '<projectId>',
/**
* enable non-blocking renderer
* <link rel="preload" href="xxx" as="style" onload="this.rel='stylesheet'">
* default: true
*/
defer: true
},
// Google Fonts API V2
google: {
/**
* enable preconnect link injection
* <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
* default: true
*/
preconnect: false,
/**
* values: auto, block, swap(default), fallback, optional
* default: 'swap'
*/
display: 'block',
/**
* values: auto, block, swap(default), fallback, optional
* default: undefined
*/
text: 'ViteAwsom',
/**
* Fonts families lists
*/
families: [
// families can be either strings (only regular 400 will be loaded)
'Source Sans Pro',
// or objects
{
/**
* Family name (required)
*/
name: 'Roboto',
/**
* Family styles
*/
styles: 'ital,wght@0,400;1,200',
/**
* enable non-blocking renderer
* <link rel="preload" href="xxx" as="style" onload="this.rel='stylesheet'">
* default: true
*/
defer: true
}
]
},
})
],
}
```
## Ressources
- https://web.dev/optimize-webfont-loading/
- https://csswizardry.com/2020/05/the-fastest-google-fonts/
- _(unmaintained)_ https://www.npmjs.com/package/webfontloader

View File

@ -1,30 +0,0 @@
import { HtmlTagDescriptor } from 'vite';
declare type GoogleFontFamily = {
name: string;
styles?: string;
defer?: boolean;
};
declare type GoogleFonts = {
families: (string | GoogleFontFamily)[];
text?: string;
display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional';
preconnect?: boolean;
};
declare type TypeKitFonts = {
id: string;
defer?: boolean;
};
declare type VitePluginFontsOptions = {
google?: GoogleFonts;
typekit?: TypeKitFonts;
};
declare function VitePluginFonts(options?: VitePluginFontsOptions): {
name: string;
transformIndexHtml(): HtmlTagDescriptor[];
};
export default VitePluginFonts;
export { VitePluginFonts as Plugin, VitePluginFontsOptions };

View File

@ -1,138 +0,0 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/google-fonts.ts
var GoogleFontsBase = "https://fonts.googleapis.com/css2";
function injectFonts({
families,
text,
preconnect = true,
display = "swap"
}) {
const specs = [];
const deferedSpecs = [];
const tags = [];
if (!Array.isArray(families)) {
console.warn("Google font families is required");
return tags;
}
if (families.length >= 0) {
for (const family of families) {
if (typeof family === "string") {
deferedSpecs.push(family);
continue;
}
if (!family)
continue;
const {
name,
styles,
defer = true
} = family;
if (!name) {
console.warn("A google font family name is missing");
continue;
}
let spec = name;
if (typeof styles === "string")
spec += `:${styles}`;
if (defer)
deferedSpecs.push(spec);
else
specs.push(spec);
}
}
if (preconnect && specs.length + deferedSpecs.length > 0) {
tags.push({
tag: "link",
attrs: {
rel: "preconnect",
href: "https://fonts.gstatic.com/",
crossorigin: true
}
});
}
if (deferedSpecs.length > 0) {
let href = `${GoogleFontsBase}?family=${deferedSpecs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href
}
});
}
if (specs.length > 0) {
let href = `${GoogleFontsBase}?family=${specs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href
}
});
}
return tags;
}
var google_fonts_default = injectFonts;
// src/typekit.ts
var TypekitFontBase = "https://use.typekit.net/";
function injectFonts2({
id,
defer = true
}) {
const tags = [];
if (typeof id !== "string") {
console.warn("A Typekit id is required");
return tags;
}
if (defer) {
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href: `${TypekitFontBase}${id}.css`
}
});
} else {
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href: `${TypekitFontBase}${id}.css`
}
});
}
return tags;
}
var typekit_default = injectFonts2;
// src/index.ts
function VitePluginFonts(options = {}) {
return {
name: "vite-plugin-fonts",
transformIndexHtml() {
const tags = [];
if (options.typekit)
tags.push(...typekit_default(options.typekit));
if (options.google)
tags.push(...google_fonts_default(options.google));
return tags;
}
};
}
var src_default = VitePluginFonts;
exports.Plugin = VitePluginFonts; exports.default = src_default;

View File

@ -1,138 +0,0 @@
// src/google-fonts.ts
var GoogleFontsBase = "https://fonts.googleapis.com/css2";
function injectFonts({
families,
text,
preconnect = true,
display = "swap"
}) {
const specs = [];
const deferedSpecs = [];
const tags = [];
if (!Array.isArray(families)) {
console.warn("Google font families is required");
return tags;
}
if (families.length >= 0) {
for (const family of families) {
if (typeof family === "string") {
deferedSpecs.push(family);
continue;
}
if (!family)
continue;
const {
name,
styles,
defer = true
} = family;
if (!name) {
console.warn("A google font family name is missing");
continue;
}
let spec = name;
if (typeof styles === "string")
spec += `:${styles}`;
if (defer)
deferedSpecs.push(spec);
else
specs.push(spec);
}
}
if (preconnect && specs.length + deferedSpecs.length > 0) {
tags.push({
tag: "link",
attrs: {
rel: "preconnect",
href: "https://fonts.gstatic.com/",
crossorigin: true
}
});
}
if (deferedSpecs.length > 0) {
let href = `${GoogleFontsBase}?family=${deferedSpecs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href
}
});
}
if (specs.length > 0) {
let href = `${GoogleFontsBase}?family=${specs.join("&family=")}`;
if (typeof display === "string" && display !== "auto")
href += `&display=${display}`;
if (typeof text === "string" && text.length > 0)
href += `&text=${text}`;
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href
}
});
}
return tags;
}
var google_fonts_default = injectFonts;
// src/typekit.ts
var TypekitFontBase = "https://use.typekit.net/";
function injectFonts2({
id,
defer = true
}) {
const tags = [];
if (typeof id !== "string") {
console.warn("A Typekit id is required");
return tags;
}
if (defer) {
tags.push({
tag: "link",
attrs: {
rel: "preload",
as: "style",
onload: "this.rel='stylesheet'",
href: `${TypekitFontBase}${id}.css`
}
});
} else {
tags.push({
tag: "link",
attrs: {
rel: "stylesheet",
href: `${TypekitFontBase}${id}.css`
}
});
}
return tags;
}
var typekit_default = injectFonts2;
// src/index.ts
function VitePluginFonts(options = {}) {
return {
name: "vite-plugin-fonts",
transformIndexHtml() {
const tags = [];
if (options.typekit)
tags.push(...typekit_default(options.typekit));
if (options.google)
tags.push(...google_fonts_default(options.google));
return tags;
}
};
}
var src_default = VitePluginFonts;
export {
VitePluginFonts as Plugin,
src_default as default
};

View File

@ -1,34 +0,0 @@
{
"name": "vite-plugin-fonts",
"version": "0.2.2",
"description": "Webfont loader for vite",
"author": "stafyniaksacha",
"repository": "stafyniaksacha/vite-plugin-fonts",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"dev": "npm run build -- --watch",
"example:dev": "npm -C example run dev",
"example:build": "npm -C example run build",
"build": "tsup src/index.ts --dts --format cjs,esm",
"lint": "eslint --ext .ts ./src",
"lint:fix": "eslint --fix --ext .ts ./src"
},
"peerDependencies": {
"vite": "^2.0.0"
},
"devDependencies": {
"@antfu/eslint-config-ts": "^0.5.0",
"@typescript-eslint/eslint-plugin": "^4.17.0",
"eslint": "^7.22.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"tsup": "^4.6.1",
"typescript": "^4.2.3",
"vite": "^2.0.5"
}
}

1
node_modules/vite-plugin-fonts generated vendored
View File

@ -1 +0,0 @@
.pnpm/vite-plugin-fonts@0.2.2/node_modules/vite-plugin-fonts

View File

@ -1,5 +0,0 @@
{
"devDependencies": {
"vite-plugin-fonts": "^0.2.2"
}
}

View File

@ -1,15 +0,0 @@
lockfileVersion: 5.3
specifiers:
vite-plugin-fonts: ^0.2.2
devDependencies:
vite-plugin-fonts: 0.2.2
packages:
/vite-plugin-fonts/0.2.2:
resolution: {integrity: sha512-fhzhsrTiuzlDjSO6g5sV5EVIIvbb8lmsaIY6eUTBM4lcF55x40UBpHrcyvNwIhQG211g0lu83XC7oZlkmvdkMA==}
peerDependencies:
vite: ^2.0.0
dev: true