Skip to content

Commit 73a3c91

Browse files
committed
Merge branch 'release/4.2.0'
2 parents d0a123c + 13111ca commit 73a3c91

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [4.2.0](https://github.com/ravorona/sage/compare/4.1.1...4.2.0) (2023-04-26)
2+
3+
4+
### Features
5+
6+
* Enable/Disable hot module replacement automatically ([c926f03](https://github.com/ravorona/sage/commit/c926f036d7b74193287126dc328e9d57b0ccb7de))
7+
18
### [4.1.1](https://github.com/ravorona/sage/compare/4.1.0...4.1.1) (2023-04-26)
29

310

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ themes/your-theme-name/ # → Root of your Sage based theme
7474

7575
### Build commands
7676

77-
- `yarn dev` — Start dev server
77+
- `yarn dev` — Start dev server and hot module replacement
7878
- `yarn build` — Compile assets
7979
- `yarn lint` — Lint stylesheets & javascripts
8080
- `yarn lint:css` — Lint stylesheets
@@ -87,19 +87,20 @@ themes/your-theme-name/ # → Root of your Sage based theme
8787
Add the following variables in your project `.env`
8888

8989
```sh
90-
# If true hot reload is active.
91-
# If not specified or set to false, and if the `public/manifest.json` file is missing, HMR is automatically enabled.
92-
HMR_ENABLED=true
93-
9490
# Endpoint where the bundler serve your assets
95-
HMR_ENTRYPOINT=http://example.com:3000
91+
HMR_ENTRYPOINT=http://localhost:5173
9692
```
9793

9894
#### Theme side
9995

10096
For advanced dev server configuration, copy `.env.example` according
10197
to [Vite naming convention and loading order](https://vitejs.dev/guide/env-and-mode.html#env-files) and update variables
10298

99+
#### FYI
100+
101+
Running HMR Mode remove the `public/manifest.json` file, so do not forget to re-run the assets compilation
102+
with `yarn build` if needed.
103+
103104
## Documentation
104105

105106
- [Sage documentation](https://roots.io/sage/docs/)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ravorona/sage",
3-
"version": "4.1.1",
3+
"version": "4.2.0",
44
"description": "Wordpress theme based on Sage starter theme using Vite",
55
"license": "MIT",
66
"authors": [

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ravorona/sage",
3-
"version": "4.1.1",
3+
"version": "4.2.0",
44
"description": "Wordpress theme based on Sage starter theme using Vite",
55
"license": "MIT",
66
"scripts": {

vite.config.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
*/
2121

22+
import { unlink } from 'fs'
2223
import * as path from 'path'
2324
import copy from 'rollup-plugin-copy'
2425
import outputManifest, { KeyValueDecorator, OutputManifestParam } from 'rollup-plugin-output-manifest'
2526
import { ConfigEnv, defineConfig, loadEnv, UserConfigExport } from 'vite'
2627

28+
const publicDir = 'public'
29+
const manifestFile = 'manifest.json'
2730
const assets = {
2831
base: 'resources',
2932
scripts: 'resources/scripts',
@@ -56,7 +59,7 @@ export default defineConfig(({ mode }: ConfigEnv) => {
5659
build: {
5760
sourcemap: 'inline',
5861
manifest: false,
59-
outDir: 'public',
62+
outDir: publicDir,
6063
assetsDir: '',
6164
rollupOptions: {
6265
input: {
@@ -68,7 +71,7 @@ export default defineConfig(({ mode }: ConfigEnv) => {
6871
},
6972
plugins: [
7073
outputManifest({
71-
fileName: 'manifest.json',
74+
fileName: manifestFile,
7275
generate:
7376
(keyValueDecorator: KeyValueDecorator, seed: object, opt: OutputManifestParam) => chunks =>
7477
chunks.reduce((manifest, { name, fileName }) => {
@@ -114,15 +117,15 @@ export default defineConfig(({ mode }: ConfigEnv) => {
114117
targets: [
115118
{
116119
src: path.resolve(__dirname, `${assets.base}/images/**/*`),
117-
dest: 'public/images'
120+
dest: `${publicDir}/images`
118121
},
119122
{
120123
src: path.resolve(__dirname, `${assets.base}/svg/**/*`),
121-
dest: 'public/svg'
124+
dest: `${publicDir}/svg`
122125
},
123126
{
124127
src: path.resolve(__dirname, `${assets.base}/fonts/**/*`),
125-
dest: 'public/fonts'
128+
dest: `${publicDir}/fonts`
126129
}
127130
]
128131
})
@@ -137,6 +140,10 @@ export default defineConfig(({ mode }: ConfigEnv) => {
137140
const protocol = 'http'
138141
const https = !!(devServerConfig.HMR_HTTPS_KEY && devServerConfig.HMR_HTTPS_CERT)
139142

143+
unlink(`${publicDir}/${manifestFile}`, error =>
144+
console.log(`🧹 Wipe ${manifestFile} :`, error ? `No ${manifestFile} in the public directory` : '✅')
145+
)
146+
140147
devServerConfig.HMR_HOST && (host = devServerConfig.HMR_HOST)
141148
devServerConfig.HMR_PORT && (port = parseInt(devServerConfig.HMR_PORT))
142149

0 commit comments

Comments
 (0)