javascript - Cannot disable LiveReloading webapck dev server for my react app - Stack Overflow

hers my webpack config which i used for my project.const HtmlWebPackPlugin = require("html-webpack

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",

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742291550a4416282.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信