-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ItinerisLtd/add-set-config-function
Added default configuration
- Loading branch information
Showing
7 changed files
with
751 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,8 @@ | ||
{ | ||
"name": "bud-favicons", | ||
"version": "0.0.0", | ||
"version": "0.0.15", | ||
"description": "Bud.js extension to automatically generate favicons.", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"contributors": [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Dan Lapteacru", | ||
"url": "https://github.com/danlapteacru" | ||
} | ||
], | ||
"main": "index.js", | ||
"license": "MIT", | ||
"homepage": "https://github.com/ItinerisLtd/bud-favicons", | ||
"repository": { | ||
|
@@ -27,38 +18,44 @@ | |
"webpack-favicons", | ||
"favicons-webpack-plugin" | ||
], | ||
"files": [ | ||
"docs", | ||
"lib", | ||
"src" | ||
"contributors": [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Dan Lapteacru", | ||
"url": "https://github.com/danlapteacru" | ||
} | ||
], | ||
"type": "module", | ||
"exports": { | ||
".": "./lib/index.js" | ||
".": "./lib/index.js", | ||
"./types": "./lib/types.js" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
".": [ | ||
"./lib/types/index.d.ts", | ||
"./lib/index.d.ts" | ||
"./lib/index.js" | ||
], | ||
"types": [ | ||
"./lib/types.js" | ||
] | ||
} | ||
}, | ||
"types": "./lib/index.d.ts", | ||
"module": "./lib/index.js", | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"devDependencies": { | ||
"@types/node": "20.14.12" | ||
}, | ||
"dependencies": { | ||
"@roots/bud": "^6.23.3", | ||
"@roots/bud-framework": "^6.23.3", | ||
"@roots/bud-support": "^6.23.3", | ||
"@roots/bud-typescript": "^6.23.3", | ||
"favicons": "^7.2.0", | ||
"favicons-webpack-plugin": "^6.0.1", | ||
"tslib": "2.6.3" | ||
"@types/node": "18.17.9", | ||
"tslib": "2.6.2" | ||
}, | ||
"volta": { | ||
"extends": "../../../package.json" | ||
"dependencies": { | ||
"favicons": "^7.1.4", | ||
"favicons-webpack-plugin": "^6.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,73 @@ | ||
import {type Bud, type WebpackPluginInstance} from '@roots/bud-framework' | ||
import {Bud} from "@roots/bud-framework"; | ||
import {Extension} from '@roots/bud-framework/extension' | ||
import { | ||
bind, | ||
dependsOn, | ||
expose, | ||
label, | ||
} from '@roots/bud-framework/extension/decorators' | ||
|
||
import {type BudFaviconsPublicOptions} from './types.js' | ||
import FaviconsWebpackPlugin from "favicons-webpack-plugin"; | ||
import {bind, label, expose} from '@roots/bud-framework/extension/decorators' | ||
import FaviconsWebpackPlugin from 'favicons-webpack-plugin' | ||
import merge from '@roots/bud-support/merge' | ||
import type {WebpackPluginInstance} from '@roots/bud-framework/config' | ||
import type {BudFaviconsPublicOptions} from "./types.js"; | ||
|
||
/** | ||
* Favicons extension | ||
* BudFavicons extension for handling favicons in the Bud framework. | ||
* | ||
* @label `bud-favicons` | ||
* @expose `favicons` | ||
*/ | ||
@label(`bud-favicons`) | ||
@dependsOn(['favicons-webpack-plugin']) | ||
@expose(`favicons`) | ||
export default class BudFavicons extends Extension< | ||
BudFaviconsPublicOptions, | ||
WebpackPluginInstance | ||
> { | ||
/** | ||
* {@link Extension.register} | ||
* Options for the favicons. | ||
* @private | ||
*/ | ||
private faviconOptions: {}|BudFaviconsPublicOptions = {}; | ||
|
||
/** | ||
* Creates an instance of FaviconsWebpackPlugin with merged options. | ||
* | ||
* @param {Bud} app - The Bud application instance. | ||
* @returns {Promise<WebpackPluginInstance>} - The FaviconsWebpackPlugin instance. | ||
*/ | ||
@bind | ||
public override async make(app: Bud): Promise<WebpackPluginInstance> { | ||
return new FaviconsWebpackPlugin(merge({}, this.defaultOptions(app), this.faviconOptions)); | ||
} | ||
|
||
/** | ||
* Sets up the favicon options. | ||
* | ||
* @param {BudFaviconsPublicOptions} options - The options for the favicons. | ||
*/ | ||
@bind | ||
public override async configAfter(bud : Bud) : Promise<void> { | ||
new FaviconsWebpackPlugin(this.options); | ||
public setup(options: BudFaviconsPublicOptions): void { | ||
this.faviconOptions = options; | ||
} | ||
} | ||
|
||
export type * from './types.js' | ||
/** | ||
* Provides the default options for the favicons. | ||
* | ||
* @param {Bud} app - The Bud application instance. | ||
* @returns {BudFaviconsPublicOptions} - The default options for the favicons. | ||
* @private | ||
*/ | ||
private defaultOptions(app: Bud): BudFaviconsPublicOptions { | ||
return { | ||
logo: app.path('resources/images/favicon.svg'), | ||
mode: 'webapp', | ||
devMode: 'webapp', | ||
outputPath: app.path('public'), | ||
favicons: { | ||
icons: { | ||
android: true, | ||
appleIcon: true, | ||
appleStartup: true, | ||
favicons: true, | ||
windows: true, | ||
yandex: false, | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,17 @@ | ||
import type BudFavicons from './index.js' | ||
|
||
import type {FaviconWebpackPlugionOptions} from "favicons-webpack-plugin/src/options.js"; | ||
import BudFavicons from "./index.js"; | ||
import type {Rule} from "@roots/bud-framework"; | ||
|
||
declare module '@roots/bud-framework' { | ||
interface Bud { | ||
favicons: BudFavicons, | ||
} | ||
interface BudFaviconsPublicOptions extends FaviconWebpackPlugionOptions {} | ||
|
||
export {type BudFaviconsPublicOptions} | ||
|
||
declare module '@roots/bud-framework' { | ||
interface Modules { | ||
'bud-favicons': BudFavicons, | ||
'bud-favicons': BudFavicons | ||
} | ||
|
||
interface Rules { | ||
js: Rule, | ||
ts: Rule, | ||
interface Bud { | ||
favicons: BudFavicons | ||
} | ||
} | ||
|
||
interface BudFaviconsPublicOptions extends FaviconWebpackPlugionOptions {} | ||
|
||
export {type BudFaviconsPublicOptions} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.