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

Watch mode doesn't work #22

Open
NullVoxPopuli opened this issue Jun 4, 2024 · 5 comments · May be fixed by embroider-build/embroider#2126
Open

Watch mode doesn't work #22

NullVoxPopuli opened this issue Jun 4, 2024 · 5 comments · May be fixed by embroider-build/embroider#2126

Comments

@NullVoxPopuli
Copy link
Collaborator

I make a change to a file with the server running

  • page does not refresh / no network activity
  • after manual refresh, changes are not reflected
@mansona
Copy link
Member

mansona commented Jun 5, 2024

This is a known issue and isn't really a concern of this blueprint, it's marked Currently breaking behaviors that we're working on in this issue embroider-build/embroider#1860

I'm going to leave this issue open in case anyone else tries to report this issue but it's not something that is a concern of the blueprint, it's a concern of Embroider itself 👍

@AmilKey

This comment was marked as off-topic.

@mansona

This comment was marked as off-topic.

@AmilKey

This comment was marked as off-topic.

@Jopie01
Copy link

Jopie01 commented Aug 13, 2024

I don't know if it is the same thing or the right thing to do, but I walked into the same kind of problem today. I wanted to try the new way to build my app so I installed the bleeding edge (I think)

npx ember-cli@latest new my-fancy-app -b @embroider/app-blueprint --pnpm --skip-git --skip-npm

But then after running pnpm start it didn't do live-reload. Changes made to a file triggered vite to do a rebuild, but the page didn't refresh.
I searched a bit what to do and found https://stackoverflow.com/questions/70996320/enable-hot-reload-for-vite-react-project-instead-of-page-reload. Adding usePolling: true to the watch keyword in my vite.config.mjs was enough to start automatic refreshing the page.

This is now my vite.config.mjs

import { defineConfig } from 'vite';
import {
  resolver,
  hbs,
  scripts,
  templateTag,
  optimizeDeps,
  compatPrebuild,
  assets,
  contentFor,
} from '@embroider/vite';
import { resolve } from 'path';
import { babel } from '@rollup/plugin-babel';

const root = 'tmp/rewritten-app';
const extensions = [
  '.mjs',
  '.gjs',
  '.js',
  '.mts',
  '.gts',
  '.ts',
  '.hbs',
  '.json',
];

export default defineConfig(({ mode }) => {
  return {
    root,
    cacheDir: resolve('node_modules', '.vite'),
    resolve: {
      extensions,
    },
    plugins: [
      hbs(),
      templateTag(),
      scripts(),
      resolver(),
      compatPrebuild(),
      assets(),
      contentFor(),

      babel({
        babelHelpers: 'runtime',
        extensions,
      }),
    ],
    optimizeDeps: optimizeDeps(),
    publicDir: resolve(process.cwd(), 'public'),
    server: {
      port: 4200,
      host: '0.0.0.0',  // added because I want to connect over the network
      watch: {
        usePolling: true,  // added to do live-reload
        ignored: ['!**/tmp/rewritten-app/**'],
      },
    },
    build: {
      outDir: resolve(process.cwd(), 'dist'),
      rollupOptions: {
        input: {
          main: resolve(root, 'index.html'),
          ...(shouldBuildTests(mode)
            ? { tests: resolve(root, 'tests/index.html') }
            : undefined),
        },
      },
    },
  };
});

function shouldBuildTests(mode) {
  return mode !== 'production' || process.env.FORCE_BUILD_TESTS;
}

@mansona mansona linked a pull request Sep 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants