This JavaScript library allows you to develop your Skouerr blocks, a suite of tools dedicated to designing WordPress themes. This command-line tool enables you to launch the compilation of your blocks and start an HMR (Hot Module Replacement) server for interactive development. Based on Vite, the Skouerr starter theme facilitates the rapid compilation of your assets within modular blocks, thereby optimizing the performance and modularity of your projects.
You only need to install one npm module:
npm install skouerr-scripts
or
yarn add skouerr-scripts
This CLI provides commands to add to your development scripts in the package.json file of the theme directory.
{
"scripts": {
"build": "skouerr-scripts build",
"watch": "skouerr-scripts watch"
}
}
For the build command to execute correctly, the templates.json file must be present at the root of the theme.
When developing multiple projects, you can select a different port for each one.
skouerr-scripts watch -p <PORT>
In the WordPress theme, it is possible to modify the port that will run the development script.
add_filter('wp_sk_scripts_port', function(){
return <PORT>
})
This project uses Socket.IO, which imposes CORS issues. Therefore, we need to specify a development URL, which defaults to http://localhost. You can modify it using a command-line parameter.
skouerr-scripts watch --dev-url <URL>
A script using Chokidar monitors file changes. When a modification is detected, the build scripts are triggered. The build process is managed by ViteJS.
WordPress and PHP do not offer a native, performant solution for real-time development on a document. Therefore, we have implemented a file reloading system. Events are emitted via Socket.IO to handle reloads and error displays.
The HTML tags affected by the changes are removed before being re-injected, allowing for style updates.
JavaScript files are reloaded on every modification, which is not optimal.
PHP, Twig, and other files containing textual content modify the current page using a diff-dom based system. When a new page is fetched via a fetch request, the new elements are injected into the current page.
We welcome contributions to this project! If you would like to contribute, please follow the steps below to ensure a smooth integration of your changes.
If you have any feedback, please reach out to us at contact@skouerr.dev