Webpack React 热加载不适用于子文件夹中的文件
Webpack React Hot Loading not working for files in sub folders
Webpack 热重新加载仅适用于指定文件夹 'react-frontend' 中的文件,但不适用于该文件夹子文件夹中的文件。奇怪的是,在我最近将我的机器从 Ubuntu 重置为 Debian 之前,它一直在工作。我猜 npm 在这个新系统上安装了略有不同的版本。有什么想法吗?
var path = require('path');
var webpack = require('webpack');
publicPath = 'http://localhost:3000/';
module.exports = {
devtool: 'eval',
node: {
fs: 'empty'
},
entry: {
artistbox: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/artistbox'
],
analysis: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/analysis'
],
visualize: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/visualize'
]
},
output: {
path: path.join(__dirname, 'public', 'javascripts'),
filename: '[name].js',
publicPath: publicPath
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['', '.js', '.cjsx', '.coffee']
},
module: {
loaders: [
{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'react-frontend')
},
{
test: /\.cjsx$/,
loaders: ['react-hot', 'coffee', 'cjsx'],
include: path.join(__dirname, 'react-frontend')
},
{
test: /\.coffee$/,
loaders: ['coffee'],
include: path.join(__dirname, 'react-frontend')
}
]
}
};
编辑:好的,我可以确定原因不是 webpack 配置。我刚刚在我的 windows 机器上部署了这个项目,它运行良好。所以看起来它与 Debian 有关。事实上,我 运行 Linux Mint Debian Edition。
是的,问题出在OS这边。 Debian 或 Linux Mint Debian Edition 似乎具有相对较低的 inotify 监视限制。我正在使用的 IntelliJ 实际上一直在给我警告,我一直忽略它。
通过关注these instructions我可以解决问题。
Webpack 热重新加载仅适用于指定文件夹 'react-frontend' 中的文件,但不适用于该文件夹子文件夹中的文件。奇怪的是,在我最近将我的机器从 Ubuntu 重置为 Debian 之前,它一直在工作。我猜 npm 在这个新系统上安装了略有不同的版本。有什么想法吗?
var path = require('path');
var webpack = require('webpack');
publicPath = 'http://localhost:3000/';
module.exports = {
devtool: 'eval',
node: {
fs: 'empty'
},
entry: {
artistbox: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/artistbox'
],
analysis: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/analysis'
],
visualize: [
'webpack-dev-server/client?' + publicPath,
'webpack/hot/only-dev-server',
'./react-frontend/visualize'
]
},
output: {
path: path.join(__dirname, 'public', 'javascripts'),
filename: '[name].js',
publicPath: publicPath
},
plugins: [
new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['', '.js', '.cjsx', '.coffee']
},
module: {
loaders: [
{
test: /\.js$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'react-frontend')
},
{
test: /\.cjsx$/,
loaders: ['react-hot', 'coffee', 'cjsx'],
include: path.join(__dirname, 'react-frontend')
},
{
test: /\.coffee$/,
loaders: ['coffee'],
include: path.join(__dirname, 'react-frontend')
}
]
}
};
编辑:好的,我可以确定原因不是 webpack 配置。我刚刚在我的 windows 机器上部署了这个项目,它运行良好。所以看起来它与 Debian 有关。事实上,我 运行 Linux Mint Debian Edition。
是的,问题出在OS这边。 Debian 或 Linux Mint Debian Edition 似乎具有相对较低的 inotify 监视限制。我正在使用的 IntelliJ 实际上一直在给我警告,我一直忽略它。
通过关注these instructions我可以解决问题。