4 ms·
Have things changed since http://jlongster.com/Backend-Apps-with-Webpack--Part-I http://jlongster.com/Backend-Apps-with-Webpack--Part-I ? It sounded like there
by sync 11y ago
Have things changed since http://jlongster.com/Backend-Apps-with-Webpack--Part-I http://jlongster.com/Backend-Apps-with-Webpack--Part-I ? It sounded like there were a ton of workarounds to get Webpack working on the backend.
- Ambroos 11y agoIt's not as much of a mess as it seems there. I started out with James Long's config as well but quickly simplified everything and ended up with the following (left out some project-specific stuff): https://gist.github.com/Ambroos/8299d0c0d322cd3a736d https://gist.github.com/Ambroos/8299d0c0d322cd3a736d As most complex things in Webpack do, it still feels like a hack at first. Using simply /^(?!\.|\/).+/i in externals is way easier than scanning the filesystem for module names and usually more reliable. You simply assume that everything that is accessed with a relative path is local, and everything else is an external module. Add libraryTarget: 'commonjs' to tell Webpack to simply use classic requires for externals and to bundle everything up in the end, and you're done. Add loaders and plugins to your own preference. You end up with one giant Javascript file that, when ran through Node, does exactly what you expect it to (but still requires NPM dependencies externally, so you can't 'just' use the bundled file without npm install).