Reputation: 3830
I'm trying to figure out how to get webpack to watch an NPM linked dependency. I've tried to add an explicit entry pointing into the package, and I've tried to both explicitly includ it and also not excluding /node_modules/ (which is quite common).
The scenario I want to achieve is as follows: I want to separate out parts of my react-based applications into component libraries (NPM packages).
Both the main package and the dependencies are written in ES6, so I've created a small gulp script that watches for changes in the dependent project, and transpiles its source (src/) to lib.
I've used npm link
to wire in the dependent package so that I don't need to pack/publish/reinstall it every time I make a change.
When I make changes to the dependent package, the gulp task transpiles the code OK.
It is with the last part that I am struggling; getting webpack watch
to trigger a re-bundling when the dependency is refreshed by the aforementioned gulp task.
Upvotes: 23
Views: 3086
Reputation: 7684
Make sure you transpiler script doesn't delete your old /lib
dir, but overwrites files instead.
I had a similar problem with Webpack dev server not seeing changes because I was removing the /lib
dir before every transpile.
Upvotes: 5