From 220972ba0829fa5e687a3f14849194ced686a706 Mon Sep 17 00:00:00 2001 From: tjcouch-sil Date: Thu, 2 Nov 2023 10:33:11 -0500 Subject: [PATCH] Allow data urls --- src/webpack-env.d.ts | 108 +++++++++++++++++++++++++++++++++ webpack/webpack.config.base.ts | 19 ++++++ 2 files changed, 127 insertions(+) diff --git a/src/webpack-env.d.ts b/src/webpack-env.d.ts index f1f6b71..a2eb21e 100644 --- a/src/webpack-env.d.ts +++ b/src/webpack-env.d.ts @@ -54,4 +54,112 @@ declare module '*.css' { // #endregion +// #region images + +/** + * Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.png' { + const content: string; + export default content; +} + +/** + * Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.svg' { + const content: string; + export default content; +} + +/** + * Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.jpg' { + const content: string; + export default content; +} + +/** + * Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.jpeg' { + const content: string; + export default content; +} + +/** + * Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.gif' { + const content: string; + export default content; +} + +// #endregion + +// #region fonts + +/** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.woff' { + const content: string; + export default content; +} + +/** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.woff2' { + const content: string; + export default content; +} + +/** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.eot' { + const content: string; + export default content; +} + +/** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.ttf' { + const content: string; + export default content; +} + +/** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ +declare module '*.otf' { + const content: string; + export default content; +} + +// #endregion + // #endregion diff --git a/webpack/webpack.config.base.ts b/webpack/webpack.config.base.ts index 1e1e6ed..68122da 100644 --- a/webpack/webpack.config.base.ts +++ b/webpack/webpack.config.base.ts @@ -101,6 +101,25 @@ const configBase: webpack.Configuration = { 'sass-loader', ], }, + /** Load images as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ + // https://webpack.js.org/guides/asset-management/#loading-images + { + test: /\.(png|svg|jpg|jpeg|gif)$/i, + type: 'asset/inline', + }, + /** + * Load fonts as data uris + * + * Note: it is generally advised to use the `papi-extension:` protocol to load assets + */ + // https://webpack.js.org/guides/asset-management/#loading-fonts + { + test: /\.(woff|woff2|eot|ttf|otf)$/i, + type: 'asset/inline', + }, /** * Import files with no transformation as strings with "./file?raw" */