Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build issues #589

Closed
andrewatduckpin opened this issue Feb 1, 2025 · 2 comments
Closed

Build issues #589

andrewatduckpin opened this issue Feb 1, 2025 · 2 comments

Comments

@andrewatduckpin
Copy link

andrewatduckpin commented Feb 1, 2025

I am trying to deploy my built theme to WP Engine using Github Actions, but the resulting build has issues with asset references.

The assets are created in the dist directory, but the references are not correct. For instance, in the <head> of the document, the reference to the main stylesheet is "main.scss", not the compiled main.css file in the dist directory.

<link rel="stylesheet" id="Flynt/assets/main-css" href="https://domain.com/wp-content/themes/theme-name/assets/main.scss" media="all">

Here is my Github workflow. Is there a reason the resulting build wouldn't have correct asset references? It is following the same process I use on my local:

  1. Checkout code
  2. composer install
  3. npm install
  4. npm run build:production
name: Deploy to WP Engine
on:
  push:
    branches:
      - staging
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    environment:
      name: ${{ github.ref_name }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          path: build
      - name: Run composer install
        working-directory: build
        run: composer install
      - name: Run npm install
        working-directory: build
        run: npm install
      - name: Build Theme
        working-directory: build
        run: npm run build:production
      - name: GitHub Action Deploy to WP Engine
        uses: wpengine/github-action-wpe-site-deploy@v3
        with:
          WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
          WPE_ENV: ${{ secrets.WPE_INSTALL_NAME }}
          SRC_PATH: "build/"
          REMOTE_PATH: "wp-content/themes/${{ secrets.REPO_NAME }}/"
          CACHE_CLEAR: TRUE
Image
@timohubois
Copy link
Contributor

timohubois commented Feb 11, 2025

@andrewatduckpin assuming you are using Flynt >= 2 can you find a manifest file within dist/.vite/manifest.json after build and if so is this file also deployed? Further do you have any issues when you run npm run lint?

@andrewatduckpin
Copy link
Author

Thanks, that was helpful!

Turns out everything starting with . was being ignored in the deployment process, so the .vite directory containing the manifest.json file was being skipped.

For anyone else deploying to WP Engine via Github Actions, here's how we made sure the .vite directory and it's contents make it to WPE. Note the includes/excludes in FLAGS that allow for the .vite directory, but still exclude all other files/directories starting with .

- name: GitHub Action Deploy to WP Engine
        uses: wpengine/github-action-wpe-site-deploy@v3
        with:
          WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }}
          WPE_ENV: ${{ secrets.WPE_ENV }}
          SRC_PATH: "build/"
          REMOTE_PATH: ${{ secrets.THEME_PATH }}
          FLAGS: --delete -azvr --inplace --include='dist/.vite/' --include='dist/.vite/**' --exclude=.*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants