Webpack React Hot Loading not working for files in sub folders

陌路散爱 提交于 2021-02-10 00:45:35

问题


Webpack hot reloading is working only for the files in the specified folder 'react-frontend', but not for files in subfolders of that folder. The strange thing is that it was working before I recently reset my machine from Ubuntu to Debian. I guess npm has installed slightly different versions on this new system. Any idea?

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')
      }
    ]
  }
};

Edit: OK I can definitely confirm that the reason is not the webpack config. I have just deployed this project on my windows machine and it works perfectly. So it looks like it has to do with Debian. I am running the Linux Mint Debian Edition in fact.


回答1:


Yes, the problem is on the OS side. It seems that Debian or Linux Mint Debian Edition comes with a relatively low inotify watch limit. IntelliJ which I am using has been giving me warning in fact, which I kept on ignoring.

By following these instructions I could solve the problem.



来源:https://stackoverflow.com/questions/35367533/webpack-react-hot-loading-not-working-for-files-in-sub-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!