How to Deploy a Vite WordPress Theme
This guide outlines how to deploy WordPress themes built with Vite, using our gulp
-based workflow.
β οΈ Note: If your project uses Webpack, the deploy process is different. See below for how to identify the type of project and where to get more info.
π§ Is It a Vite or Webpack Project?
Section titled βπ§ Is It a Vite or Webpack Project?βTo determine whether a project is using Vite or Webpack, check the root of the theme folder:
- Vite projects will have a
vite.config.js
file. - Webpack projects will have files like
webpack.common.js
,webpack.dev.js
, orwebpack.prod.js
.
π You should always confirm this by reviewing the project setup guide:
https://terradocs.netlify.app/wp/terra-framework/before-running/
π¦ Deployment
Section titled βπ¦ DeploymentβInside your theme project, youβll find a file named sftpConfig.js
.
All deploy operations are routed through this configuration file to ensure consistency and reduce risk.
The available Gulp tasks have been simplified and standardized. Here are the main commands you can run:
π Gulp Tasks
Section titled βπ Gulp Tasksβ-
gulp ddist --dev|stage|production
β Upload all project files. -
gulp ddisthash --dev|stage|production
β Upload only the/dist
and/hash
directories. -
gulp dfm --dev|stage|production
β Deploy all flexible modules. -
gulp dall --dev|stage|production
β Deploy everything in the project. -
gulp dphp --dev|stage|production
β Deploy only PHP files. -
gulp ds --dev|stage|production --path footer.php
β Deploy a specific file. -
gulp ds --dev|stage|production --path folder/
β Deploy a specific folder. -
gulp remove --dev|stage|production --path footer.php
β Remove a specific file or folder from the server.
π Reminder: Always update the hash in
define-hash.php
(or similar) whenever you generate a newdist
folder after making changes to JS or CSS.
π Excluding Files from Upload
Section titled βπ Excluding Files from UploadβTo prevent certain files from being uploaded, make sure they are listed in the filesToExclude
constant inside sftpConfig.js
.
Example:
const filesToExclude = [ "!functions/project/hash.php", "!functions/project/local/local-variable.php", "!public/**/*", "!config/**/*", "!node_modules/**/*", "!src/**/*", "!.env.production", "!.env.virtual", "!gulpfile.js", "!package-lock.json", "!package.json", "!readme.md", "!vite.config.js", "!documentation/**/*",];
π This ensures that sensitive or non-deployable files are not accidentally pushed to the server.
π§ Summary
Section titled βπ§ Summaryβ- Always confirm the project type (Vite vs. Webpack).
- For Vite projects, use the
gulp
commands defined above. - Use
ddisthash
ordphp
depending on what has changed.
π¬ When in doubt, confirm with the lead developer before deploying to stage or production.