To allow the creation of ad hoc webpack loaders.
Inspired by gulp-tap.
npm install --save-dev passthrough-loader
const webpackConfig = {
entry: [
'file?./index.html!passthrough!./index.tmpl'
],
passthrough: {
callback: function renderTemplate(source) {
return renderMyTemplate(source);
}
}
}
My specific use case was trying to use an HTML template library and send the output through more loaders. I wasn't able to achieve this using the HTMLWebpackPlugin because of inherent limitations to webpack plugins without polluting the template files with webpack syntax, or using a webpack specific workaround.
There are webpack loaders that are more similar than different, and yet, may not have configurations to support each individual use case, or interface with the libraries they are implementing. If a loader does not meet ad hoc requirements, the passthrough loader allows the creation of a loader that will.