Webpack loader
Drop-in source location injection for Webpack 5.
What it does#
A standard Webpack 5 loader that injects data-wv-source into JSX/TSX files. Same transform as the Vite and SWC variants, exposed as a loader.
Wire it up#
// webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(tsx|jsx)$/,
exclude: /node_modules/,
enforce: "pre",
loader: "weevar/webpack-loader",
},
],
},
};
enforce: "pre" runs the loader before your TypeScript / Babel loader, so the attributes are present in the source the rest of your pipeline sees.
The loader does nothing on files that don't match .jsx / .tsx, and falls open if its internal transform fails.
With Create React App#
CRA doesn't allow custom Webpack configs out of the box. Use CRACO to add the loader rule, or eject. (CRA users: consider migrating to Vite. It’s a one-evening job and Weevar's Vite path is the most polished.)