conditional-pragma-loader

webpack loader to ignore remaining loaders when the file does not contain a pragma.

Usage no npm install needed!

<script type="module">
  import conditionalPragmaLoader from 'https://cdn.skypack.dev/conditional-pragma-loader';
</script>

README

conditional-pragma-loader

A webpack loader to ignore remaining loaders when the file does not contain a pragma.

Example

This will only run the babel-loader on *.js files that contain the pragma comment: /** @babel */.

// webpack.config.js
...
loaders: [
    {
        test: /\.js$/,
        loaders: [
            'conditional-pragma-loader?pragma=babel',
            'babel-loader'
        ]
    }
]
...

Caveats

Currently only works when chained with one additional loader