Skip to content

webpack watch mode not working.... #2949

@mastrauckas

Description

@mastrauckas

General Information:
webpack version: 1.13.2
OS: Windows 10 Anniversary Update and webpack is running in Windows Subsystem for Linux(The new bash on Ubuntu)

I"m trying to run webpack in watch mode by using:

webpack --watch

and by also setting watch mode in config:

context: path.join(__dirname, '/src'),
devtool: debug ? 'inline-sourcemap' : null,
entry: './js-src/scripts.js',
watch: true,
module: {

All webpack does is run the transpiler and exit.
Example of output when running watch mode:

Hash: 045070ba2ed9ce40edf7
Version: webpack 1.13.2
Time: 2146ms
         Asset     Size  Chunks             Chunk Names
scripts.min.js  1.89 MB       0  [emitted]  main
    + 172 hidden modules

I'm not sure what i'm doing incorrect?

Activity

TheLarkInn

TheLarkInn commented on Sep 4, 2016

@TheLarkInn
Member
  1. Could you please first post your question on stack overflow before you post here. Our issue template clearly encourages submitters to submit their questions/support there so that you have more accessible support. When you have submitted the question to stackoverflow, please provide the link there for easier access.
  2. Could you please provide your full webpack configuration.
mastrauckas

mastrauckas commented on Sep 4, 2016

@mastrauckas
Author

Since I think it's a possible issue I think this is the appropriate place because it might be an issue.: Full webpack config:

var debug = process.env.NODE_ENV !== 'production';
var path = require('path');
var webpack = require('webpack');

module.exports = {
  context: path.join(__dirname, '/src'),
  devtool: debug ? 'inline-sourcemap' : null,
  entry: './js-src/scripts.js',
  watch: true,
  module: {
    loaders: [
      {
        test: /.js?$/,
        exclude: /(node_modules)|(bower_components)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015', 'stage-0']
        }
      }
    ]
  },
  output: {
    path: path.join(__dirname, '/src/wwwroot/static/js'),
    filename: 'scripts.min.js'
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
};

Thanks!

sokra

sokra commented on Sep 5, 2016

@sokra
Member

OS: Windows 10 Anniversary Update and webpack is running in Windows Subsystem for Linux(The new bash on Ubuntu)

Probably chokidar has an issue with this...

TheLarkInn

TheLarkInn commented on Sep 5, 2016

@TheLarkInn
Member

Their issue list has a few maybe related things. @mastrauckas is there any additional details that you think might be beneficial that we (you could also as well) could submit to @paulmillr?

mastrauckas

mastrauckas commented on Sep 5, 2016

@mastrauckas
Author

@TheLarkInn I have no additional information. Should I just put a ticket on their issue list and refer back to this ticket?

paulmillr

paulmillr commented on Sep 5, 2016

@paulmillr

@mastercactapus I would be glad to help you (i've created chokidar). Are you able to set up a demo git repo that makes it easy to replicate the issue?

mastrauckas

mastrauckas commented on Sep 5, 2016

@mastrauckas
Author

@paulmillr I can pull down any demo you want me too from git and run it. I might not be able to do it until tomorrow though.

25 remaining items

swordman1205

swordman1205 commented on Jul 29, 2017

@swordman1205

watchOptions: {
poll: true
}

Thank you. This solution works for me.

ankitrg

ankitrg commented on Aug 11, 2017

@ankitrg

I am on webpack 3, and I have poll option enabled, still Webpack picks up first few writes and then doesn't do that. I have tried saving the files via emacs and atom.

dzwiedziu-nkg

dzwiedziu-nkg commented on Oct 27, 2017

@dzwiedziu-nkg

I have similar problem on Linux Mint 18.2. After fix inotify issue works fun :)

toididau456

toididau456 commented on Feb 22, 2018

@toididau456

@lahdo thank you!

vladshlianin

vladshlianin commented on Jul 23, 2018

@vladshlianin

@lahdo I know, It's a ghost thread, but still - thank you, I've really struggled with this issue!

hijackthegit

hijackthegit commented on Aug 7, 2018

@hijackthegit

@lahdo thank you too, saved my day, literally!

barisusakli

barisusakli commented on Feb 24, 2020

@barisusakli

For anyone stumbling upon this when using the node API, having

watchOptions: {
  poll: true
}

In the webpack config didn't work for me, I had to feed it into the compiler.watch function, not sure if this is intended.

const webpack = require('webpack');

const compiler = webpack({
  // these options do not seem to effect compiler.watch
  watchOptions: { 
    poll: true,
  },
});

const watching = compiler.watch({
  poll: true // this works
}, (err, stats) => { // Stats Object
  console.log(stats);
});
ChrisTsou

ChrisTsou commented on Apr 9, 2020

@ChrisTsou

For googlers,
On wsl 2 you have to set poll, poll: 1000 worked for me.

zatloeri

zatloeri commented on Oct 11, 2020

@zatloeri

This just happened to me (Putting it here because this is where it led me).
The compilation starts and finishes without any error, but it does not continue to watch for changes.
It acts as if watch is disabled.

My webpack.config.js is:

module.exports = () => ({
    entry: path.resolve(__dirname, 'src/index.ts'),
    mode: NODE_ENV,
    watch: true,
    target: 'node',
...
// rest of config (uninportant I think)
...
}

And I am running webpack via NODE_ENV=development webpack

I found the problem in my case is combination of

"webpack": "^4.44.2",
"webpack-cli": "^4.0.0",

If I change webpack-cli to version "^3.3.12" and update my deps, then everything works as expected.
Don't know why this is, but I hope it can help somebody solving the problem for themselves.
Also should mention that I am using:

yarn version - 1.22.4
node version - v14.13.0
alexander-akait

alexander-akait commented on Oct 11, 2020

@alexander-akait
Member

@zatloeri Please create reproducible test repo and open an issue in webpack-cli

miadabdi

miadabdi commented on Oct 23, 2020

@miadabdi

I had this problem, just updated webpack-cli from 4.0.0 to 4.1.0 and it fixed it!

aaronamm

aaronamm commented on Dec 29, 2020

@aaronamm

@lahdo Thank you so much. It works.
Here is part of my Webpack setting.

module.exports = {
  watchOptions: {
    ignored: /node_modules/,
    poll: true
  }
};
  • "webpack": "4.31.0",
  • "webpack-cli": "3.3.2",
  • "webpack-dev-server": "3.10.3"
  • WSL 2
  • Distributor ID: Ubuntu
  • Description: Ubuntu 18.04.5 LTS
  • Release: 18.04
  • Codename: bionic
    FYI webpack watch option
    https://webpack.js.org/configuration/watch/#watchoptionspoll
    However, but I still don't understand that I don't have to set this option when I use Windows.
    If someone can explain, I will appreciate it.
    Thanks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bebraw@bmayen@paulmillr@eteeselink@rafde

        Issue actions

          webpack watch mode not working.... · Issue #2949 · webpack/webpack