jekyll-minify-js 0.2.1 → 0.2.12
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.
- checksums.yaml +4 -4
- data/README.md +130 -0
- data/assets/index.js +50 -0
- data/assets/index.js.map +7 -0
- data/lib/jekyll-minify-js.rb +103 -70
- data/lib/version.rb +5 -1
- metadata +17 -26
- data/lib/color.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc6f30042ff95a354ae677e257b3b63e32c28f8db6e90c07a7c5b1a094317d0b
|
|
4
|
+
data.tar.gz: de98fd673ddf78c0c65572c8c5e9a75c003336a1c068c6dbae604918eaefe300
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df46d5c1c8afba1ac339ddb5a24b4ae741f24ebca4657219c3bf7204a3da7a7f1ebd0fd246207318a476f5dc90f71bceea164316be22bb942a6ad800a1f5127e
|
|
7
|
+
data.tar.gz: 0b202faa2e48abee76e3fff2efc52da6073d8d4fb6f444dc7d676ad75bfd6c0b94122f0248301c6d0107bbfe6a2a4c95ed49ec09a377462ce6a426d677a9d65f
|
data/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 -->
|
|
2
|
+
<!-- markdownlint-disable MD041 -->
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://pub-c9ba018358dd48a99b70013b65a25e5f.r2.dev/logo/rubygems_logo.webp" width="160" height="160" alt="ruby"/>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">Jekyll Minify Js</h1>
|
|
7
|
+
|
|
8
|
+
Jekyll plugin that minifies JavaScript files with Terser after the site is written.
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- Minifies all `.js` files from a configurable source directory.
|
|
13
|
+
- Writes minified output into a configurable destination directory.
|
|
14
|
+
- Generates source maps by default.
|
|
15
|
+
- Falls back to copying the original file if minification fails.
|
|
16
|
+
|
|
17
|
+
## Requirements
|
|
18
|
+
|
|
19
|
+
- Ruby 3.1+
|
|
20
|
+
- Jekyll 4.4+
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Add the gem to your Jekyll site's `Gemfile`:
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
gem 'jekyll-minify-js'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then install dependencies:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
bundle install
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
|
|
38
|
+
Add a `minify_js` section to `_config.yml`:
|
|
39
|
+
|
|
40
|
+
```yml
|
|
41
|
+
minify_js:
|
|
42
|
+
enable: true
|
|
43
|
+
entry_dir: js
|
|
44
|
+
output_dir: js
|
|
45
|
+
terser_opts:
|
|
46
|
+
compress: true
|
|
47
|
+
mangle: true
|
|
48
|
+
source_map: true
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Options
|
|
52
|
+
|
|
53
|
+
| Option | Type | Default | Description |
|
|
54
|
+
| ------------ | ------- | ------- | -------------------------------------------------------------------- |
|
|
55
|
+
| `enable` | boolean | `true` | Set to `false` to skip minification. |
|
|
56
|
+
| `entry_dir` | string | `js` | Directory inside your source site containing input JavaScript files. |
|
|
57
|
+
| `output_dir` | string | `js` | Directory inside `_site` where minified files are written. |
|
|
58
|
+
| `compress` | boolean | `true` | Enables Terser compression. |
|
|
59
|
+
| `mangle` | boolean | `true` | Enables Terser name mangling. |
|
|
60
|
+
| `source_map` | boolean | `true` | Generates `.map` files and appends `sourceMappingURL`. |
|
|
61
|
+
|
|
62
|
+
## How It Works
|
|
63
|
+
|
|
64
|
+
During Jekyll's `post_write` hook, the plugin:
|
|
65
|
+
|
|
66
|
+
1. Reads JavaScript files from `entry_dir`.
|
|
67
|
+
2. Minifies each file with Terser.
|
|
68
|
+
3. Writes the result to `_site/output_dir`.
|
|
69
|
+
4. Writes a source map when `source_map` is enabled.
|
|
70
|
+
5. Copies the original file if Terser raises an error for that file.
|
|
71
|
+
|
|
72
|
+
Directory structure example:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
your-site/
|
|
76
|
+
js/
|
|
77
|
+
app.js
|
|
78
|
+
vendor/
|
|
79
|
+
search.js
|
|
80
|
+
_site/
|
|
81
|
+
js/
|
|
82
|
+
app.js
|
|
83
|
+
app.js.map
|
|
84
|
+
vendor/
|
|
85
|
+
search.js
|
|
86
|
+
search.js.map
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Example
|
|
90
|
+
|
|
91
|
+
If your source files live in `assets/js` and you want output in `assets/js` inside `_site`:
|
|
92
|
+
|
|
93
|
+
```yml
|
|
94
|
+
minify_js:
|
|
95
|
+
entry_dir: assets/js
|
|
96
|
+
output_dir: assets/js
|
|
97
|
+
compress: true
|
|
98
|
+
mangle: true
|
|
99
|
+
source_map: true
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
Install dependencies:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
bundle install
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Run checks:
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
bundle exec rubocop
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Generate YARD documentation:
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
bundle exec yard doc lib/**/*.rb README.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Check documentation coverage without generating HTML:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
bundle exec yard stats lib/**/*.rb
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
Released under the MIT License. See `LICENSE.txt`.
|