Vite not finding built app.js in staging in sage 11

When I deploy my app to my staging environment, it’s an EBS docker image. I’ve had this working great on sage 10. I should mention WP_ENV and WP_ENVIRONMENT are set to “staging” in this environment.

When I exec into my docker image, /var/www/html is where nginx is pointed. Within that, my compiled vite files are at /var/www/html/web/app/themes/jecoaching-sage/public/build.

When I hit the site, vite complains:

“Unable to locate file in Vite manifest: resources/js/app.js”

Here’s my vite.config.js file.

import {defineConfig} from 'vite';
import tailwindcss from '@tailwindcss/vite';
import laravel from 'laravel-vite-plugin';
import {viteStaticCopy} from 'vite-plugin-static-copy';
import {wordpressPlugin, wordpressThemeJson} from '@roots/vite-plugin';

export default defineConfig({
  server: {
    host: '0.0.0.0',
    port: 5173,
    hmr: {
      host: 'localhost',
      protocol: 'ws',
      port: 5173,
    },
  },
  base: '/app/themes/jecoaching-sage/public/build/',
  plugins: [
    tailwindcss(),
    laravel({
      input: [
        'resources/css/app.css',
        'resources/js/app.ts',
        'resources/css/editor.css',
        'resources/js/editor.ts',
        'resources/js/devpathfinder/index.ts',
        'resources/js/coaching-prospects/index.ts',
        'resources/js/consulting-accelerator-application/index.ts',
      ],
      refresh: true,
    }),

    wordpressPlugin(),

    // Generate the theme.json file in the public/build/assets directory
    // based on the Tailwind config and the theme.json file from base theme folder
    wordpressThemeJson({
      disableTailwindColors: true,
      disableTailwindFonts: true,
      disableTailwindFontSizes: true,
    }),

    viteStaticCopy({
      targets: [
        {src: 'resources/browserconfig.xml', dest: 'assets'},
        {src: 'resources/favicon.ico', dest: 'assets'},
        {src: 'resources/mstile-150x150.png', dest: 'assets'},
        {src: 'resources/site.webmanifest', dest: 'assets'},
        {
          src: 'resources/js/getGAConsent.js',
          dest: 'assets',
        },
      ],
    }),
  ],
  resolve: {
    alias: {
      '@scripts': '/resources/js',
      '@styles': '/resources/css',
      '@fonts': '/resources/fonts',
      '@images': '/resources/images',
    },
  },
});

Did you change app.js to app.ts at sage/resources/views/layouts/app.blade.php at 5ffb5636b2eae99afd6522eaba7e7809d8b939f5 · roots/sage · GitHub

No I did not! I didn’t know vite would still work locally and not in prod unless that was a typescript extension. Just tried it and deployed it - bingo! Thanks @Log1x

1 Like

No problem! It’s possible the view was cached so it just appeared to work before.