It seems like Webpack runs tools that transform code via "loaders", rather than using the APIs of those tools directly. This adds a layer of abstraction over those tools which sometimes means the APIs of the tools is not fully exposed or updates to the tools take time to be updated in the loader. Here's a more detailed description of the problem.
I ran into this problem with Grunt/gulp, and ended up abandoning those in favor of transforming my source directly with bash scripts that I run via npm. Is it possible to do the same thing with Webpack? If so, how?
I created a custom Webpack loader called
shell-loader
that takes an arbitrary shell script and runs it on the content of each file that it loads usingchild_process.exec
. I can use it like this inwebpack.config.js
;It seems to work, as a proof of concept, but I'm not sure if this is a good idea when working with Webpack, or if I'm hacking things together that they weren't meant to be.