admin管理员组

文章数量:1332389

hers my webpack config which i used for my project.

const HtmlWebPackPlugin = require("html-webpack-plugin");
const LiveReloadPlugin = require("webpack-livereload-plugin");
const DotenvPlugin = require('webpack-dotenv-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');

module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'index.bundle.js',
    publicPath: '/'
  },
  mode: 'development',
  devtool: 'source-map',
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true,
    port: 8080,
    host: '0.0.0.0',
    disableHostCheck: true,
  },
  module: {
    rules: [
      .........
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    }),
    new DotenvPlugin({
      sample: './.env',
      path: './.env'
    }),
    //new BundleAnalyzerPlugin()
  ]
};

here is my script from package.json file

"app-start": "webpack-dev-server --config ./webpack.dev.config.js --open",

even after adding this

"app-start": "webpack-dev-server --config ./webpack.dev.config.js --no-inline --no-hot --open",

it doesnt work.

I've also tried putting the hot:false within the webpack config file yet it still reloades the project on save of code.

am i doing something wrong yes please correct.

hers my webpack config which i used for my project.

const HtmlWebPackPlugin = require("html-webpack-plugin");
const LiveReloadPlugin = require("webpack-livereload-plugin");
const DotenvPlugin = require('webpack-dotenv-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');

module.exports = {
  entry: [
    './src/index.js'
  ],
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'index.bundle.js',
    publicPath: '/'
  },
  mode: 'development',
  devtool: 'source-map',
  devServer: {
    historyApiFallback: true,
    noInfo: true,
    overlay: true,
    port: 8080,
    host: '0.0.0.0',
    disableHostCheck: true,
  },
  module: {
    rules: [
      .........
    ]
  },
  plugins: [
    new HtmlWebPackPlugin({
      template: "./src/index.html",
      filename: "./index.html"
    }),
    new DotenvPlugin({
      sample: './.env',
      path: './.env'
    }),
    //new BundleAnalyzerPlugin()
  ]
};

here is my script from package.json file

"app-start": "webpack-dev-server --config ./webpack.dev.config.js --open",

even after adding this

"app-start": "webpack-dev-server --config ./webpack.dev.config.js --no-inline --no-hot --open",

it doesnt work.

I've also tried putting the hot:false within the webpack config file yet it still reloades the project on save of code.

am i doing something wrong yes please correct.

Share asked May 15, 2019 at 6:13 SnivioSnivio 1,8641 gold badge20 silver badges27 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 3

I understood that you want to avoid the live reload of the application once you do any changes in your code base.

so please try the below config , It might help.

devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true,
port: 8080,
host: '0.0.0.0',
disableHostCheck: true,
hot: false,
inline: false

}

make sure you have ejected the webpack using 'npm run eject'.

Running the server with webpack-dev-server --liveReload false could help I believe.

It worked Now I changed the run script to :

    "app-start": "webpack-dev-server --config ./webpack.dev.config.js --no-inline",

本文标签: javascriptCannot disable LiveReloading webapck dev server for my react appStack Overflow