You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-66Lines changed: 5 additions & 66 deletions
Original file line number
Diff line number
Diff line change
@@ -542,76 +542,15 @@ WDS BT is equipped with automated workflow actions that ensure code security and
542
542
543
543
## Automated Versioning Process
544
544
545
-
This theme uses an automated versioning system that increments the `BUILD` number automatically upon merges to the `main` branch. The `VERSION` is manually controlled and is reflected in the `composer.json` and `package.json` files. The `BUILD` number is automatically appended to the `VERSION`in`style.css`.
545
+
To handle cache busting for CSS and JS files, this theme automatically appends the file modification time as a version parameter to the URLs of enqueued styles and scripts, ensuring that browsers fetch the most recent version whenever the files are updated.
546
546
547
-
<details>
548
-
<summary><strong>How It Works</strong></summary>
549
-
550
-
1. **VERSION**: Manually setin the `.env` file. This is reflected in the `composer.json` and `package.json` files.
551
-
- Format: `X.Y.Z` (Semantic Versioning)
552
-
- This value is manually updated by the developer.
553
-
554
-
2. **BUILD**: Automatically increments on merges to the `main` branch. This is appended to the `VERSION`in the `style.css` file.
555
-
- Format: `1.0.0x` where `x` is the build number.
556
-
557
-
</details>
558
-
559
-
<details>
560
-
<summary><strong>Example</strong></summary>
561
-
562
-
Suppose the `.env` file has the following values:
563
-
564
-
```plaintext
565
-
VERSION=1.0.0
566
-
BUILD=4
567
-
```
568
-
569
-
After merging a PR into the `main` branch:
570
-
571
-
- The `BUILD` increments to `5`.
572
-
- The version in`style.css` becomes `Version: 1.0.005`.
573
-
- The `composer.json` and `package.json` will still reflect `1.0.0`.
574
-
575
-
</details>
576
-
577
-
<details>
578
-
<summary><strong>Modifying the Version</strong></summary>
579
-
580
-
- To update the `VERSION`, manually edit the `.env` file:
581
-
```plaintext
582
-
VERSION=1.1.0
583
-
BUILD=0
584
-
```
585
-
- The `BUILD` should not be manually modified except for specific scenarios, such as resetting the build number after a major version change.
586
-
587
-
</details>
588
547
589
548
<details>
590
-
<summary><strong>Workflow</strong></summary>
591
-
592
-
When a PR is merged into the `main` branch, the following occurs automatically:
593
-
594
-
1. The `BUILD` number increments.
595
-
2. The `style.css` is updated to reflect the `VERSION + BUILD`.
596
-
3. The `composer.json` and `package.json` files are updated with only the `VERSION`.
597
-
4. The updated files are committed back to the `main` branch.
You can manually trigger the versioning process locally if necessary by running:
605
-
606
-
```bash
607
-
npm run update-version
608
-
```
609
-
610
-
This will:
549
+
<summary><strong>How It Works</strong></summary>
611
550
612
-
- Increment the `BUILD` number.
613
-
- Update the version in`style.css`.
614
-
- Ensure `composer.json` and `package.json` reflect the correct `VERSION`.
551
+
1. Hooking into the `style_loader_src` and `script_loader_src` filters, which handle the URLs of enqueued styles and scripts.
552
+
2. Using the `filemtime()`functionto retrieve the last modified time of the `style.css` file, appending it as the version (`ver`) parameter in the asset URLs.
553
+
3. This ensures that browsers always fetch the latest version of your CSS and JS files, preventing them from serving cached versions after updates.
0 commit comments