-
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 #10 from wide/new-js-builder
New js builder
- Loading branch information
Showing
6 changed files
with
144 additions
and
23 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
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { loadRC, write } from '../workspace' | ||
import path from 'path' | ||
import favicons from 'favicons' | ||
|
||
|
||
/** | ||
* Compile favicons files | ||
* @param {Object} ctx | ||
* @param {Array} ctx.files favicons to compile | ||
* @param {String} ctx.dest folder to write favicons | ||
*/ | ||
export default async function(ctx) { | ||
|
||
// get .faviconsrc | ||
const rc = loadRC('favicons', { | ||
icons: { | ||
android: true, | ||
appleIcon: true, | ||
appleStartup: false, | ||
coast: false, | ||
favicons: true, | ||
firefox: false, | ||
opengraph: false, | ||
twitter: false, | ||
windows: true, | ||
yandex: false | ||
} | ||
}) | ||
|
||
// compile and return files | ||
return compile(ctx.files, ctx.dest, rc) | ||
} | ||
|
||
|
||
/** | ||
* Compile one favicon file | ||
* @param {String|Array<String>} files Files to compile | ||
* @param {String} dest Destination to write files | ||
* @param {Object} rc Favicon moodule configuration | ||
*/ | ||
async function compile(files, dest, rc) { | ||
// create the favicons | ||
const stats = await favicons(files, rc) | ||
|
||
// store written images | ||
const compiled = [] | ||
|
||
// loop over all images and write them | ||
for (const favicon of stats.images) { | ||
// create the path to the destination files | ||
// will be wrote | ||
const faviconPath = path.resolve(dest, favicon.name) | ||
|
||
// add file to the list to return | ||
compiled.push(await write(faviconPath, favicon.contents)) | ||
} | ||
|
||
// return compiled images | ||
return compiled | ||
} |
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
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