2017-07-31 309 views
0

webpack-dev-serverの停止方法を知っている人はいますか?私は関係なく、私は一度か二度、それを押して、それが動作しないのです、はCtrl +CはCtrl +Zを使用しようとしました。さらに、私はコマンドラインインターフェイスを閉じても、それはまだ動作します。そして、私がサーバポートを変更しても、以前のサーバポートはまだ動作します。だから私は、CLIを閉じるとき、またはwebpack.config.jsのいくつかのパラメータを変更したいときに毎回サーバポートを変更しなければならない。ここで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 = { 
 
\t entry: { 
 
\t \t main: './src/main.js' 
 
\t }, 
 
\t output: { 
 
\t \t path: path.resolve(__dirname, 'dist'), 
 
\t \t filename: 'bundle.js', 
 
\t }, 
 
\t devtool: false, 
 
\t module: { 
 
\t \t rules: [{ 
 
\t \t \t test: /\.css$/, 
 
\t \t \t use: ExtractTextPlugin.extract({ 
 
\t \t \t \t fallback: "style-loader", 
 
\t \t \t \t use: "css-loader" 
 
\t \t })},{ 
 
\t \t \t test: /\.(js|jsx)?$/, 
 
\t \t \t use: ['babel-loader'], 
 
\t \t \t exclude: /node_modules/ 
 
\t \t }] 
 
\t }, 
 
\t devServer: { 
 
\t \t contentBase: './dist', 
 
\t \t hot: true, 
 
\t \t port: 8088, 
 
\t }, 
 
\t plugins: [ 
 
\t \t new HtmlWebpackPlugin({ 
 
\t \t \t title: "Hello React", 
 
\t \t \t template: "template.html", 
 
\t \t }), 
 
\t \t new webpack.HotModuleReplacementPlugin(), 
 
\t \t new ExtractTextPlugin("style.bundle.css") 
 
\t ] 
 
};

そして、ここでは私のpackage.json Addtionally

{ 
 
    "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 <[email protected]>", 
 
    "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" 
 
    } 
 
}

あり、そこにされます私の罪唯一の窓: enter image description here

見ての通り、私はCtrlキー + 二度Cを押したが、その後、私は、ファイルの内容を変更し、WebPACKの-devのサーバーが再度コンパイルし、私はまだ、コンテンツを見ることができますブラウザを更新してください。

+1

私はCtrl + Cを使用して、すべてのプラットフォームでそれを停止しました。他に何かがあるはずです – rossipedia

+0

Ctrl + Cを使用しようとすると、あなたのコンソールのスクリーンショットを投稿できますか? – FuriousD

+0

'q'を押すと便利ですか? –

答えて

1

プロセスの名前がわかっている場合は、このコマンドを使用してプロセスを強制終了できます。 は、私はちょうどインラインが役立つかもしれないとの "Ctrl + C" が2回、WebPACKの-devのサーバーを停止

0
"start": "webpack-dev-server --inline --progress --port 8088" 

はそれを使用します。

ルートディレクトリで設定ファイルを検索します.configファイルは、設定ファイルがディレクトリのどこかにある場合にのみ使用することをお勧めします。

+1

またはconfigは、アプリケーション環境に応じていくつかのwebpack設定がある場合に便利です – Disfigure

関連する問題