I have a webpack loader in my configuration which I want to run only
- in Watch Mode
- Starting with the second run (or any other condition that might change with each individual watch build triggered by file changes)
What I already have:
module.exports = (env, argv) {
const isWatchMode = argv.watch;
module: {
rules: [
...(isWatchMode
? [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
…
}
}]
: []),
…
],
},
…
};
This would trigger the loader only in watch mode, checked before the first run.
How do I include it depending on a condition that could change every run?