webfont-builder 1.0.0
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/LICENSE +21 -0
- package/README.md +65 -0
- package/package.json +23 -0
- package/src/index.js +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Jesus Graterol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# WebFont Builder
|
|
2
|
+
|
|
3
|
+
The `webfont-builder` package is a simple script which purpose is to help build Web Fonts so they can be easily self-hosted in production-grade applications.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
1. Install `webfont-builder` in the font package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ npm install -D webfont-builder
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Invoke the builder:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
$ webfont-builder
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<br/>
|
|
24
|
+
|
|
25
|
+
## Built With
|
|
26
|
+
|
|
27
|
+
- JavaScript
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
<br/>
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
<br/>
|
|
44
|
+
|
|
45
|
+
## Acknowledgments
|
|
46
|
+
|
|
47
|
+
- [clean-css](https://github.com/clean-css/clean-css)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
<br/>
|
|
54
|
+
|
|
55
|
+
## Deployment
|
|
56
|
+
|
|
57
|
+
1. Install dependencies:
|
|
58
|
+
```bash
|
|
59
|
+
$ npm install
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. Publish to `npm`:
|
|
63
|
+
```bash
|
|
64
|
+
$ npm publish
|
|
65
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "webfont-builder",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The webfont-builder package is a simple script which purpose is to help build Web Fonts so they can be easily self-hosted in production-grade applications.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node src/index.js",
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/jesusgraterol/webfont-builder.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Jesus Graterol",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/jesusgraterol/webfont-builder/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/jesusgraterol/webfont-builder#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"clean-css": "^5.3.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
rmSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
cpSync
|
|
7
|
+
} from 'node:fs';
|
|
8
|
+
import CleanCSS from 'clean-css';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/* ************************************************************************************************
|
|
12
|
+
* HELPERS *
|
|
13
|
+
************************************************************************************************ */
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Removes the distribution directory and creates it again in order to guarantee a clean build.
|
|
17
|
+
*/
|
|
18
|
+
const __cleanDist = () => {
|
|
19
|
+
rmSync('dist', { recursive: true, force: true });
|
|
20
|
+
mkdirSync('dist');
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Minifies and saves the font declaration stylesheet.
|
|
25
|
+
*/
|
|
26
|
+
const __minifyFontDeclaration = () => {
|
|
27
|
+
const file = new CleanCSS().minify(['src/index.css']);
|
|
28
|
+
writeFileSync('dist/index.css', file.styles, { encoding: 'utf-8' });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Copies the raw font assets from the source into the distribution directory.
|
|
33
|
+
*/
|
|
34
|
+
const __copyFontAssets = () => cpSync('src/woff2', 'dist/woff2', { recursive: true });
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/* ************************************************************************************************
|
|
40
|
+
* EXECUTION *
|
|
41
|
+
************************************************************************************************ */
|
|
42
|
+
|
|
43
|
+
(() => {
|
|
44
|
+
// clean the distribution directory
|
|
45
|
+
__cleanDist();
|
|
46
|
+
|
|
47
|
+
// minify the font declaration
|
|
48
|
+
__minifyFontDeclaration();
|
|
49
|
+
|
|
50
|
+
// finally, copy the font assets
|
|
51
|
+
__copyFontAssets();
|
|
52
|
+
})();
|