Skip to content

Commit

Permalink
Merge pull request #30 from sn-satyendra/definition-correction
Browse files Browse the repository at this point in the history
Type and publicPath fix
  • Loading branch information
sn-satyendra authored Dec 14, 2021
2 parents d26fec7 + eae575c commit 1bcba82
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
registry=https://registry.npmjs.org/
registry=https://registry.npmjs.org/
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webpack-font-preload-plugin",
"version": "1.4.0",
"version": "1.4.1",
"description": "A webpack plugin to allow preloading or prefetching of fonts.",
"main": "src/cjs.js",
"types": "src/index.d.ts",
Expand Down
21 changes: 14 additions & 7 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import { Compiler } from "webpack";

declare class WebpackFontPreloadPlugin {
constructor(options?: WebpackFontPreloadPlugin.Options);

/**
* Webpack font preload plugin options to modify the default configuration.
*/
options?: WebpackFontPreloadPlugin.Options;

/**
* This method is called once by the webpack compiler while installing the plugin.
*/
apply(compiler: Compiler): void;
}

declare namespace WebpackFontPreloadPlugin {
interface replaceCallbackOptions {
/**
* Full source string of the index.html
*/
indexSource: string;

/**
* `<link>` tags for preloading fonts as a string
*/
linksAsString: string;
}
interface Options {
Expand Down Expand Up @@ -50,14 +64,7 @@ declare namespace WebpackFontPreloadPlugin {
* webpack build.
*/
replaceCallback?: ({
/**
* Full source string of the index.html
*/
indexSource,

/**
* `<link>` tags for preloading fonts as a string
*/
linksAsString,
}: replaceCallbackOptions) => string;

Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class WebpackFontPreloadPlugin {
const assetNames = assets && (Object.keys(assets) || []);
const index = assets[this.options.index];
const indexSource = index && index.source();
const publicPath = outputOptions && outputOptions.publicPath;
if (indexSource && publicPath) {
const publicPath = (outputOptions && outputOptions.publicPath) || "";
if (indexSource) {
let strLink = "";
assetNames.forEach((asset) => {
if (this.isFontAsset(asset) && this.isFiltered(asset)) {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
// Change this to match your project
"include": ["src/**/*"],
"compilerOptions": {
"strict": true,
Expand Down

0 comments on commit 1bcba82

Please sign in to comment.