-1

I tried in webpack encore to configure dev-server for hot reload. After making changes and pressing ctrl + s, the page refreshes and you can see the changes. But is it possible to make the changes visible without refreshing the page? The application is put in docker containers.

let config = Encore.getWebpackConfig();

config.cache = {
  type: 'filesystem',
  cacheDirectory: `${__dirname}/.webpack-cache`,
};
config.devServer = {
  host: '0.0.0.0',
  port: 8080,
  hot: true,
  watchFiles: ['assets/**/*'],
  liveReload: false,
  open: false,
  allowedHosts: 'all',
  headers: {
    'Access-Control-Allow-Origin': '*',
  },
  devMiddleware: {
    writeToDisk: false,
  },
  client: {
    overlay: false,
    logging: 'info',
    progress: true,
  },
};

module.exports = config;

after writing this code I thought that hot reload would work without refreshing the page

1 Answer 1

-1
let config = Encore.getWebpackConfig();

config.cache = {
  type: 'filesystem',
  cacheDirectory: `${__dirname}/.webpack-cache`,
};
config.devServer = {
  host: '0.0.0.0',
  port: 8080,
  hot: true,
  watchFiles: ['assets/**/*'],
  liveReload: true,
  open: false,
  allowedHosts: 'all',
  headers: {
    'Access-Control-Allow-Origin': '*',
  },
  devMiddleware: {
    writeToDisk: false,
  },
  client: {
    overlay: false,
    logging: 'info',
    progress: true,
  },
};

module.exports = config;

You forgot to update the liveReload key to true. Also check the watchFiles: ['assets/**/*']. It should point to src folder,

Reference: Document

Sample code`

.configureDevServerOptions(options => {
    options.liveReload = true;
    options.static = {
        watch: false
    };
    options.watchFiles = {
        paths: ['src/**/*.php', 'templates/**/*'],
    };
})`

Hope this will help you

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.