webpack --watch isn't compiling changed files

后端 未结 30 1015
眼角桃花
眼角桃花 2020-12-02 06:00

I tried running webpack --watch and after editing my JS files, it doesn\'t trigger an auto-recompilation.

I\'ve tried reinstalling webpack

相关标签:
30条回答
  • 2020-12-02 06:19

    If your code isn't being recompiled, try increasing the number of watchers (in Ubuntu):

    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
    

    Source: https://webpack.github.io/docs/troubleshooting.html

    0 讨论(0)
  • 2020-12-02 06:21

    Folder case sensitivity was my issue. My code calls to require() had all lowercase path names BUT the actually directories had an uppercase letter in them. I renamed all my directories to lowercase and webpack watching worked instantly.

    0 讨论(0)
  • 2020-12-02 06:22

    Updates: deleting the entire directory and git cloning afresh from repo fixes my problem.

    0 讨论(0)
  • 2020-12-02 06:22

    Possible solution: changing context to the app directory.

    I had all my webpack config files in a sub folder:

    components/
    webpack/
     development.js
    app.js
    

    In webpack/development.js, set context: path.join(__dirname, '../') solved my problem.

    0 讨论(0)
  • 2020-12-02 06:24

    If you are using Vim you should try setting backupcopy to yes rather than the default auto. Otherwise Vim will sometimes rename the original file and create a new one, which will mess up with webpack watch:

    https://github.com/webpack/webpack/issues/781

    Just add this to your vim settings if this is the case:

    set backupcopy=yes

    0 讨论(0)
  • 2020-12-02 06:25

    I had similar issue, neither webpack or rollup in watch mode ware catching the changes I made. I found out that it was basically my fault as I was changing module (.tsx file) which wasn't yet imported anywhere in the application (for example App.ts which is entry point) and I was expecting build tools to report errors I made there.

    0 讨论(0)
提交回复
热议问题