This project can be used to hot-reload any non static web application during the development stage.
For example applications written in PHP such as WordPress, Joomla and PrestaShop.
This is done by mirroring the web application in 3 main steps:
- The url normally used to access the web application is proxied.
- The base directory of the web application is watched.
- Once a modification is detected in the base directory, the proxy is reloaded.
The hot-reload is inspired by vite and implemented thanks to BrowserSync.
You need to have Node.js and npm installed on your pc. To make sure they are available run the following commands:
node --version
npm --versionFirst some definitions.
- webreloader: The directory containing the code in charge of the hot-reload locally. Aka this project.
- root: The parent directory of the webreloader project locally. And the directory containing your web application locally.
- Open your console.
- Navigate to the root.
cd $root
- Download the repository by running the following commands:
- If the root is already a GIT repository.
shell git submodule add -- https://github.com/tapmeppework/webreloader-by-proxy.git webreloader cd webreloader npm install - Otherwise
shell git clone https://github.com/tapmeppework/webreloader-by-proxy.git webreloader cd webreloader npm install
- If the root is already a GIT repository.
- Download the webreloader project as a .zip file.
- Extract the .zip file. The result will be a single non-empty folder.
- Rename the newly created folder to 'webreloader'.
- Move the folder webreloader/ to the root. Meaning place it directly under the root.
- Run the following commands:
cd $root/webreloader npm install
Move to the webreloader folder and copy the file configuration.template.json to configuration.json.
cd $root/webreloader
cp configuration.template.json configuration.jsonEach node in the config file represents a mirror. Each mirror can be described with the following information:
- Mandatory
- The TARGET: The key used as parameter to identify the mirror to load.
- The URL to be proxied.
- Optional
- The BASE_DIRECTORY (
directory) represents the relative path to the base directory to watch.- It is relative to the root.
- The root is the parent directory of the webreloader.
- If unset the root itself will be used.
- The BROWSER key is optional. If set the given browser(s), if installed, will be used. More information here.
- The DEFAULT key is optional. If set the given mirror will run implicitly if no target is entered.
- The FILES is an optional list of glob patterns to watch.
- By default the following patterns are used:
- '**/*.css'
- '**/*.gif'
- '**/*.htm'
- '**/*.html'
- '**/*.inc'
- '**/*.jpeg'
- '**/*.jpg'
- '**/*.js'
- '**/*.php'
- '**/*.png'
- '**/*.webp'
- Anything else must be added if need be.
- By default the following patterns are used:
- The IGNORE is an optional list of glob patterns to ignore.
- Currently only the webreloader is ignored.
- Anything else must be added if need be.
- The PORT is optional and used to set a specific proxy port.
- The BASE_DIRECTORY (
To start a given mirror, run the following command:
cd $root/webreloader
npm start [__TARGET__]The proxy will then open in your (default) web browser.