Vite is a build tool that provides a faster and leaner development experience.
* It can bundle your codes to output assets
* It has Hot Module Replacement (HMR) which reflects your code changes immediately without refreshing the browser
Github repo: https://github.com/aliboy08/vite-wp/
gh repo clone aliboy08/vite-wp
inside the vite directory, run the install command
npm install
include_once 'vite-wp/vite-wp.php';
add_action('wp_enqueue_scripts', function(){
FF\Vite\load_asset('src/main.js');
// only load the css files, exclude js
FF\Vite\load_asset('src/main.js', ['css_only' => true]);
});
npm run dev
npm run build
prints the contents of the /src/css/critical.scss file as inline css on the head via wp_head action hook
FF\Vite\load_critical_css();
adds defer attributes (link=preload) on css link tags, so it doesn’t render block
FF\Vite\defer_css();
Select your desired option below to share a direct link to this page.
Your friends or family will thank you later.