Skip to content

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.


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, or webpack.prod.js.

πŸ”— You should always confirm this by reviewing the project setup guide:
https://terradocs.netlify.app/wp/terra-framework/before-running/


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 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 new dist folder after making changes to JS or CSS.


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.


  • Always confirm the project type (Vite vs. Webpack).
  • For Vite projects, use the gulp commands defined above.
  • Use ddisthash or dphp depending on what has changed.

πŸ’¬ When in doubt, confirm with the lead developer before deploying to stage or production.