有人知道如何停止webpack-dev-server吗?我已经尝试使用Ctrl+C和Ctrl+Z,但无论我按一次还是两次都不起作用。此外,即使我关闭命令行界面,它仍然在运行。而且,即使我改变了服务器端口,之前的服务器端口仍然在工作。因此,每次关闭CLI或想要在webpack.config.js中更改一些参数时,我都必须更改服务器端口。
这是我的webpack.config.js:
此外,还有我的控制台窗口:输入图像描述
如您所见,我按了两次 Ctrl + C,然后更改了文件内容,webpack-dev-server 再次编译,通过刷新浏览器仍然可以看到内容。
这是我的webpack.config.js:
const path = require('path');
const HtmlWebpackPlugin = require("html-webpack-plugin");
const webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
entry: {
main: './src/main.js'
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
devtool: false,
module: {
rules: [{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: "css-loader"
})},{
test: /\.(js|jsx)?$/,
use: ['babel-loader'],
exclude: /node_modules/
}]
},
devServer: {
contentBase: './dist',
hot: true,
port: 8088,
},
plugins: [
new HtmlWebpackPlugin({
title: "Hello React",
template: "template.html",
}),
new webpack.HotModuleReplacementPlugin(),
new ExtractTextPlugin("style.bundle.css")
]
};
这里是我的package.json文件
{
"name": "react-test",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack --config webpack.config.js",
"start": "webpack-dev-server --config webpack.config.js",
"produce": "webpack -p --config webpack.config.js"
},
"author": "dongxu <dongxu2048@gmail.com>",
"license": "ISC",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"css-loader": "^0.28.4",
"html-webpack-plugin": "^2.29.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-hot-loader": "^1.3.1",
"style-loader": "^0.18.2",
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
}
}