在更改根目录名称后,Webpack dev服务器不会监视文件

我最近更改了我的根目录(package.json和webpack.config.js)的名称,现在webpack-dev-server在更改我的文件时不会更新。

这是我的webpackconfiguration:

 var debug = process.env.NODE_ENV !== "production"; var webpack = require('webpack'); var path = require('path'); module.exports = { context: path.join(__dirname, "src"), devtool: debug ? "inline-sourcemap" : null, entry: "./js/init.js", module: { loaders: [ { test: /\.jsx?$/, exclude: /(node_modules|bower_components)/, loader: 'babel-loader', query: { presets: ['react', 'es2015', 'stage-0'], plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'], } } ] }, output: { path: __dirname + "/src/", filename: "app.js" }, plugins: debug ? [] : [ new webpack.optimize.DedupePlugin(), new webpack.optimize.OccurenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }), ], devServer: { port: 3000, hot: true, historyApiFallback: { index: 'index.html' } } }; 

而我的目录看起来像这样(客户端反应是更名的文件夹):

在这里输入图像说明

让我澄清一下,这工作得很好,所以我真的不知道为什么现在不工作。

编辑:package.json中的脚本

 "scripts": { "dev": "./node_modules/.bin/webpack-dev-server --content-base src --inline --hot", "build": "webpack" }, 

你必须删除括号。 可能是因为它们没有被webpack使用的手表模块( watchpack )或系统本身最终监视的部分妥善地转义。 我build议你不要在目录或文件名中使用任何特殊字符,因为这样的错误。