reactjstypescriptmeteorwebpackhot-module-replacement

Hot Module Replacement in a Meteor app with React and TypeScript


I'm developing a web app in an environment consisting of Meteor, React, TypeScript and Webpack. Every time I make a change to a file I have to run webpack to recompile the full project and this can take a long time (20-30 seconds). Does anyone know if there is any way to recompile only the modified file (as the Webpack Hot Module Replacement or the React Hot Loader module works) within a Meteor app?

Thanks in advance!


Solution

  • Solved! It was as easy as using Webpack Watch. I created a script dev in package.json that runs meteor & webpack and added watch: true in webpack.config.js (it would be the same adding --watch in the script) so runing npm run dev starts in parallel Meteor and Webpack watching for file changes. When a file is changed, it recompiles in about just 2 seconds and refreshes the browser.