[英]Cannot disable LiveReloading webapck dev server for my react app
hers my webpack config which i used for my project. 她是我用于项目的webpack配置。
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 这是我来自package.json文件的脚本
"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. 我还尝试将hot:false放入webpack配置文件中,但仍会在保存代码时重新加载项目。
am i doing something wrong yes please correct. 我在做错什么事吗,请纠正。
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'. 确保已使用“ npm run弹出”弹出了webpack。
现在,我将运行脚本更改为:
"app-start": "webpack-dev-server --config ./webpack.dev.config.js --no-inline",
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.