@degreesign/webapp 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/index.d.ts +2 -2
- package/dist/src/types.d.ts +8 -0
- package/dist/src/utils.d.ts +3 -2
- package/dist/src/utils.js +9 -2
- package/dist/src/web.js +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -92,6 +92,10 @@ module.exports = build({
|
|
|
92
92
|
}],
|
|
93
93
|
htmlCommonElements: [],
|
|
94
94
|
obfuscateON: false,
|
|
95
|
+
preconnectLinks: [
|
|
96
|
+
"https://api.example.com",
|
|
97
|
+
{ href: "https://cdn.example.com", crossorigin: true },
|
|
98
|
+
],
|
|
95
99
|
srcDir: "src",
|
|
96
100
|
assetsDir: "assets",
|
|
97
101
|
commonDir: "code",
|
|
@@ -142,6 +146,7 @@ module.exports = build({
|
|
|
142
146
|
- **Environment Variables**: Use `.env` to securely store sensitive data.
|
|
143
147
|
- **Development Server**: Runs on `port: 3210` by default.
|
|
144
148
|
- **PWA Support**: Customise `app_icon`, `fav_icon`, and `orientation` for a native-like experience.
|
|
149
|
+
- **Preconnect**: `preconnectLinks` adds `<link rel="preconnect">` entries (e.g. your server base URL) to the page head, so the browser starts DNS/TCP/TLS for those origins early. Each entry is a URL string or an object with `href` and optional `crossorigin`. `crossorigin` is on by default; set `crossorigin: false` per link to disable.
|
|
145
150
|
- **SEO Optimisation**: Set `websiteTitle`, `websiteDescription`, and `coverImage` for better search visibility.
|
|
146
151
|
- **Pages**: Add all pages to `pagesList`.
|
|
147
152
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { build } from "./src/main";
|
|
2
|
-
import { Page } from "./src/types";
|
|
2
|
+
import { Page, PreconnectLink } from "./src/types";
|
|
3
3
|
import { readData, readJSON, writeData, writeJSON } from "./src/utils";
|
|
4
|
-
export { build, writeData, writeJSON, readData, readJSON, Page, };
|
|
4
|
+
export { build, writeData, writeJSON, readData, readJSON, Page, PreconnectLink, };
|
package/dist/src/types.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ import CssMinimizerPlugin from "css-minimizer-webpack-plugin";
|
|
|
4
4
|
export interface StringObj {
|
|
5
5
|
[key: string]: string;
|
|
6
6
|
}
|
|
7
|
+
export interface PreconnectLink {
|
|
8
|
+
/** Server base URL to preconnect to */
|
|
9
|
+
href: string;
|
|
10
|
+
/** Enable CORS for the connection; defaults to true */
|
|
11
|
+
crossorigin?: boolean;
|
|
12
|
+
}
|
|
7
13
|
export interface Page {
|
|
8
14
|
/** URI of the page */
|
|
9
15
|
uri: string;
|
|
@@ -135,6 +141,8 @@ export interface ConfigWebApp extends ConfigBase {
|
|
|
135
141
|
updateServiceWorker?: boolean;
|
|
136
142
|
/** Online reference file */
|
|
137
143
|
onlineIndicatorFile?: string;
|
|
144
|
+
/** Server base URLs for <link rel="preconnect">, CORS on by default (optional) */
|
|
145
|
+
preconnectLinks?: (string | PreconnectLink)[];
|
|
138
146
|
}
|
|
139
147
|
export interface ConfigServer extends ConfigBase {
|
|
140
148
|
/** Server Files list */
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaTags, MetaTagsInput } from "./types";
|
|
1
|
+
import { MetaTags, MetaTagsInput, PreconnectLink } from "./types";
|
|
2
2
|
declare const
|
|
3
3
|
/** Write to files */
|
|
4
4
|
writeData: (file: string, code: string) => boolean,
|
|
@@ -7,11 +7,12 @@ writeJSON: (file: string, code: any) => boolean,
|
|
|
7
7
|
/** Read files */
|
|
8
8
|
readData: (file: string, internal?: boolean) => string,
|
|
9
9
|
/** Read JSON files */
|
|
10
|
-
readJSON: (file: string, internal?: boolean) => any, metaTags: ({ author, websiteDescription, websiteName, websiteTitle, coverImageLink, coverImageDescription, publishedTime, websiteLink, dataString, theme_color, twitterUserName, appIconFile, noindex, language, isHome, keywords, }: MetaTagsInput) => MetaTags, linkTags: ({ favIconFile, timeNow, coverImageLink, canonicalURL, }: {
|
|
10
|
+
readJSON: (file: string, internal?: boolean) => any, metaTags: ({ author, websiteDescription, websiteName, websiteTitle, coverImageLink, coverImageDescription, publishedTime, websiteLink, dataString, theme_color, twitterUserName, appIconFile, noindex, language, isHome, keywords, }: MetaTagsInput) => MetaTags, linkTags: ({ favIconFile, timeNow, coverImageLink, canonicalURL, preconnectLinks, }: {
|
|
11
11
|
coverImageLink: string;
|
|
12
12
|
favIconFile: string;
|
|
13
13
|
timeNow: number;
|
|
14
14
|
canonicalURL: string;
|
|
15
|
+
preconnectLinks?: (string | PreconnectLink)[];
|
|
15
16
|
}) => string,
|
|
16
17
|
/** Check for PHP tag */
|
|
17
18
|
isPHPTag: (code: string) => boolean;
|
package/dist/src/utils.js
CHANGED
|
@@ -260,11 +260,18 @@ readJSON = (file, internal) => {
|
|
|
260
260
|
// Theme
|
|
261
261
|
"theme-color": theme_color,
|
|
262
262
|
};
|
|
263
|
-
}, linkTags = ({ favIconFile, timeNow, coverImageLink, canonicalURL, }) => `
|
|
263
|
+
}, linkTags = ({ favIconFile, timeNow, coverImageLink, canonicalURL, preconnectLinks, }) => `
|
|
264
264
|
<link rel="icon" href="${favIconFile}" type="image/x-icon">
|
|
265
265
|
<link rel="manifest" href="/app.json?v=${timeNow}">
|
|
266
266
|
<link rel="image_src" href="${coverImageLink}">
|
|
267
|
-
<link rel="canonical" href="${canonicalURL}"
|
|
267
|
+
<link rel="canonical" href="${canonicalURL}">
|
|
268
|
+
${preconnectLinks?.map(link => {
|
|
269
|
+
const { href, crossorigin = true } = typeof link == `string` ? { href: link }
|
|
270
|
+
: link;
|
|
271
|
+
return `<link rel="preconnect" href="${href}"${crossorigin ? ` crossorigin` : ``}>`;
|
|
272
|
+
})?.join(`
|
|
273
|
+
`) || ``}
|
|
274
|
+
`,
|
|
268
275
|
/** Check for PHP tag */
|
|
269
276
|
isPHPTag = (code) => code?.includes(`<?php`);
|
|
270
277
|
exports.writeData = writeData;
|
package/dist/src/web.js
CHANGED
|
@@ -46,8 +46,8 @@ const SitemapPlugin = __importStar(require("sitemap-webpack-plugin"));
|
|
|
46
46
|
const HtmlInlineCssWebpackPlugin = __importStar(require("html-inline-css-webpack-plugin"));
|
|
47
47
|
const utils_1 = require("./utils");
|
|
48
48
|
const webConfig = (params) => {
|
|
49
|
-
const { srcDir = `src`, productionDir = `public_html`, appShortName = `WebApp`, twitterUserName = `degreesign`, websiteName = `DegreeSign WebApp`, websiteDomain = `degreesign.com`, publishedTime = `2025-01-01T00:00:00+00:00`, author = `DegreeSign Team`, websiteTitle = `progressive webapp`, websiteDescription = `Webpack progressive web app`, coverImage = `degreesign_screenshot.webp`, coverImageDescription = `Screenshot of website`, background_color = `#fff`, theme_color = `#000`, appIcon = `app_icon.png`, appIconMaskable = `app_icon_maskable.png`, fav_icon = `favicon.ico`, orientation = `portrait`, pagesList = [], htmlCommonElements = [], assetsDir = `assets`, commonDir = `common`, imagesDir = `images`, pagesDir = `pages`, pageHome = `home`, htaccessCustom = ``, startURI = ``, language = `en_GB`, cssDiscardUnused = false, updateServiceWorker = false, onlineIndicatorFile = `https://degreesign.com/assets/images/Degree_Sign_Logo_2022.svg`, } = params || {};
|
|
50
|
-
const latestUpdates = (0, utils_1.readJSON)(`./updateTimes.json`) || {}, updateTimes = () => (0, utils_1.writeJSON)(`./updateTimes.json`, latestUpdates), dataString = new Date().toISOString(), timeNow = Date.now(), websiteLink = `https://${websiteDomain}`,
|
|
49
|
+
const { srcDir = `src`, productionDir = `public_html`, appShortName = `WebApp`, twitterUserName = `degreesign`, websiteName = `DegreeSign WebApp`, websiteDomain = `degreesign.com`, publishedTime = `2025-01-01T00:00:00+00:00`, author = `DegreeSign Team`, websiteTitle = `progressive webapp`, websiteDescription = `Webpack progressive web app`, coverImage = `degreesign_screenshot.webp`, coverImageDescription = `Screenshot of website`, background_color = `#fff`, theme_color = `#000`, appIcon = `app_icon.png`, appIconMaskable = `app_icon_maskable.png`, fav_icon = `favicon.ico`, orientation = `portrait`, pagesList = [], htmlCommonElements = [], assetsDir = `assets`, commonDir = `common`, imagesDir = `images`, pagesDir = `pages`, pageHome = `home`, htaccessCustom = ``, startURI = ``, language = `en_GB`, cssDiscardUnused = false, updateServiceWorker = false, onlineIndicatorFile = `https://degreesign.com/assets/images/Degree_Sign_Logo_2022.svg`, preconnectLinks = [], } = params || {};
|
|
50
|
+
const latestUpdates = (0, utils_1.readJSON)(`./updateTimes.json`) || {}, updateTimes = () => (0, utils_1.writeJSON)(`./updateTimes.json`, latestUpdates), dataString = new Date().toISOString(), timeNow = Date.now(), websiteLink = `https://${websiteDomain || `degreesign.com`}`,
|
|
51
51
|
/** Update Image URL */
|
|
52
52
|
getImageURI = (image, full) =>
|
|
53
53
|
// raw link string
|
|
@@ -234,6 +234,7 @@ Options -Indexes
|
|
|
234
234
|
coverImageLink: coverImageLinkNew,
|
|
235
235
|
canonicalURL: pageData.canonicalURL
|
|
236
236
|
|| `https://${websiteDomain}${isHome ? `` : `/${fileName}`}`,
|
|
237
|
+
preconnectLinks,
|
|
237
238
|
}),
|
|
238
239
|
pageBody: (0, utils_1.readData)(`./${srcDir}/${pagesDir}/${fileName}/${fileName}.html`),
|
|
239
240
|
filename: isHome ? `index.html` : fileName,
|