@bouygues-telecom/staticjs 0.0.6 β 0.0.8
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/README.md +151 -18
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,31 +1,164 @@
|
|
|
1
|
-
<div align=
|
|
1
|
+
<div align="center">
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# π StaticJS
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**A modern boilerplate for creating static projects**
|
|
6
|
+
|
|
7
|
+
[](https://badge.fury.io/js/%40bouygues-telecom%2Fstaticjs)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
|
|
11
|
+
_Start your static projects in seconds with an optimized architecture_
|
|
12
|
+
|
|
13
|
+
[Installation](#-installation) β’ [Usage](#-usage) β’ [Features](#-features) β’ [Examples](#-examples)
|
|
6
14
|
|
|
7
15
|
</div>
|
|
8
16
|
|
|
9
|
-
|
|
17
|
+
## π Table of Contents
|
|
18
|
+
|
|
19
|
+
- [π― About](#-about)
|
|
20
|
+
- [β¨ Features](#-features)
|
|
21
|
+
- [π Installation](#-installation)
|
|
22
|
+
- [π Usage](#-usage)
|
|
23
|
+
- [π Revalidation](#-revalidation)
|
|
24
|
+
- [βοΈ Configuration](#οΈ-configuration)
|
|
25
|
+
- [π Examples](#-examples)
|
|
26
|
+
- [π License](#-license)
|
|
27
|
+
|
|
28
|
+
## π― About
|
|
29
|
+
|
|
30
|
+
**StaticJS** is a powerful and modern boilerplate designed for creating static projects. It integrates development best practices and offers advanced features like specific page revalidation.
|
|
31
|
+
|
|
32
|
+
### Why StaticJS?
|
|
33
|
+
|
|
34
|
+
- β‘ **Ultra-fast startup** - Initialize your project in seconds
|
|
35
|
+
- π **Smart revalidation** - Rebuild specific pages on demand
|
|
36
|
+
- ποΈ **Modern architecture** - Optimized and maintainable project structure
|
|
37
|
+
- π **Production ready** - Production-ready configuration
|
|
38
|
+
- π± **Responsive** - Native support for all devices
|
|
39
|
+
|
|
40
|
+
## β¨ Features
|
|
41
|
+
|
|
42
|
+
| Feature | Description |
|
|
43
|
+
| ----------------------------- | ---------------------------------------------- |
|
|
44
|
+
| π **Fast generation** | Project creation with a single command |
|
|
45
|
+
| π **Hot Reloading** | Automatic reload during development |
|
|
46
|
+
| π¦ **Optimized build** | Production-optimized bundle |
|
|
47
|
+
| π― **Targeted revalidation** | Specific page reconstruction via API |
|
|
48
|
+
| π οΈ **Flexible configuration** | Advanced customization according to your needs |
|
|
49
|
+
| π **Performance** | Automatic performance optimizations |
|
|
50
|
+
|
|
51
|
+
## π Installation
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
|
|
55
|
+
- Node.js >= 16.0.0
|
|
56
|
+
- npm >= 7.0.0
|
|
57
|
+
|
|
58
|
+
### Global installation
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm i @bouygues-telecom/staticjs -g
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> π‘ **Tip**: Global installation allows you to use the `create-staticjs-app` command from anywhere on your system.
|
|
65
|
+
|
|
66
|
+
## π Usage
|
|
67
|
+
|
|
68
|
+
### 1. Create a new project
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
create-staticjs-app
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This command will:
|
|
75
|
+
|
|
76
|
+
- π Create the folder structure
|
|
77
|
+
- βοΈ Configure base files
|
|
78
|
+
- π¦ Prepare the development environment
|
|
79
|
+
|
|
80
|
+
### 2. Install dependencies
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
cd your-project
|
|
84
|
+
npm i
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 3. Build the project
|
|
10
88
|
|
|
11
|
-
|
|
89
|
+
```bash
|
|
90
|
+
npm run build
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 4. Start the server
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm run start
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
π **Your project is now accessible at** `http://localhost:3000`
|
|
100
|
+
|
|
101
|
+
## π Revalidation
|
|
102
|
+
|
|
103
|
+
StaticJS offers a unique **targeted revalidation** feature that allows rebuilding specific pages without rebuilding the entire project.
|
|
12
104
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
105
|
+
### Basic syntax
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
curl -X POST http://localhost:3000/revalidate \
|
|
109
|
+
-H "Content-Type: application/json" \
|
|
110
|
+
-d '{ "paths": ["page.tsx"] }'
|
|
17
111
|
```
|
|
18
112
|
|
|
19
|
-
|
|
20
|
-
- npm run build
|
|
21
|
-
- try => test.html (navigator)
|
|
113
|
+
## π Examples
|
|
22
114
|
|
|
23
|
-
|
|
115
|
+
#### Revalidate a single page
|
|
24
116
|
|
|
25
|
-
|
|
117
|
+
```bash
|
|
118
|
+
curl -X POST http://localhost:3000/revalidate \
|
|
119
|
+
-H "Content-Type: application/json" \
|
|
120
|
+
-d '{ "paths": ["home.tsx"] }'
|
|
121
|
+
```
|
|
26
122
|
|
|
123
|
+
#### Revalidate multiple pages
|
|
124
|
+
|
|
125
|
+
```bash
|
|
27
126
|
curl -X POST http://localhost:3000/revalidate \
|
|
28
|
-
-H "Content-Type: application/json" \
|
|
29
|
-
-d '{
|
|
30
|
-
|
|
31
|
-
|
|
127
|
+
-H "Content-Type: application/json" \
|
|
128
|
+
-d '{ "paths": ["home.tsx", "about.tsx", "contact.tsx"] }'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## βοΈ Configuration
|
|
132
|
+
|
|
133
|
+
### Project structure
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
your-project/
|
|
137
|
+
βββ π src/
|
|
138
|
+
β βββ π pages/ # Your pages
|
|
139
|
+
β βββ π components/ # Reusable components
|
|
140
|
+
β βββ π styles/ # Style files
|
|
141
|
+
β βββ π utils/ # Utilities
|
|
142
|
+
βββ π public/ # Static assets
|
|
143
|
+
βββ π package.json
|
|
144
|
+
βββ π server.js # StaticJS server
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## π οΈ Available scripts
|
|
148
|
+
|
|
149
|
+
| Script | Description |
|
|
150
|
+
| --------------- | -------------------------------- |
|
|
151
|
+
| `npm run build` | Build the project for production |
|
|
152
|
+
| `npm run start` | Start the production server |
|
|
153
|
+
|
|
154
|
+
## π License
|
|
155
|
+
|
|
156
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
<div align="center">
|
|
161
|
+
|
|
162
|
+
**Developed with β€οΈ by the Bouygues Telecom team**
|
|
163
|
+
|
|
164
|
+
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bouygues-telecom/staticjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"config",
|
|
@@ -15,12 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"build": "cd templates/react && rimraf dist && rimraf cache && node ../../helpers/cachePages.js && vite build --config ../../vite.config.js && tsx ../../scripts/build-html.js",
|
|
18
|
-
"start": "
|
|
18
|
+
"start": "cd templates/react && node server.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"cli-spinner": "^0.2.10",
|
|
22
22
|
"commander": "^14.0.0",
|
|
23
23
|
"giget": "^2.0.0",
|
|
24
|
+
"nodemon": "^3.1.10",
|
|
24
25
|
"path": "^0.12.7",
|
|
25
26
|
"readline": "^1.3.0",
|
|
26
27
|
"rimraf": "^6.0.1",
|