Kamil
Kamil

Reputation: 812

Disable webpack reloading

I am configuring simple webpack stack and it works, but the thing is that it makes app reloading on each file change. Is there any way to turn off reloading upon each file change? I want to manually reload page, I am also not using hot reload and I don't want to use it.

For server I am using file:

/*eslint no-console:0 */
'use strict';
require('core-js/fn/object/assign');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const config = require('./webpack.config');
const open = require('open');

new WebpackDevServer(webpack(config), config.devServer)
.listen(config.port, 'localhost', (err) => {
  if (err) {
    console.log(err);
  }
  console.log('Listening at localhost:' + config.port);
  console.log('Opening your system browser...');
  open('http://localhost:' + config.port + '/webpack-dev-server/');
});

And for webpack configuration these are some parts:

module.exports = {
  additionalPaths: additionalPaths,
  port: defaultSettings.port,
  debug: true,
  devtool: 'eval',
  output: {
    path: path.join(__dirname, '/../dist'),
    filename: '[name].js',
    publicPath: defaultSettings.publicPath
  },
  devServer: {
    contentBase: './src/',
    historyApiFallback: true,
    hot: false,
    port: defaultSettings.port,
    publicPath: defaultSettings.publicPath,
    noInfo: false
  },
  resolve: {
    extensions: ['', '.js', '.jsx'],
    alias: {
      plugins: `${defaultSettings.srcPath}/../plugins`,
      core: `${defaultSettings.srcPath}/../core`
    }
  }
};

and dev config:

let config = Object.assign({}, baseConfig, {
  entry: {
    start: ['./src/index'],
    vendors: [],
    core: './plugins/lunchbadger-core/index',
    plugins: infoFile.plugins.map((plugin) => { return ('./plugins/lunchbadger-' + plugin); })
  },
  cache: true,
  devtool: 'eval',
  plugins: [
    new webpack.NoErrorsPlugin()
  ],
  module: defaultSettings.getDefaultModules()
});

Upvotes: 3

Views: 4595

Answers (2)

kcpr
kcpr

Reputation: 1105

It's kind of an old question, but right now webpack-dev-server --liveReload false could help in this case I believe.

Upvotes: 1

Perhaps the solution is to skip webpack-dev-server in this case and run webpack in watch mode (webpack --watch) instead? The watch mode will recompile your files as it detects changes.

In this case yu would have to serve your site separately (say using serve) but this combination would achieve what you want.

Upvotes: 1

Related Questions