问题描述:

I currently have a Webpack rule that looks like this:

{ test: /\.tsx?$/, loaders: ['@ngtools/webpack', 'babel-loader', 'angular2-template' ] }

I want only the babel-loader to exclude certain files, basically just passing them as is down the chain. The remainder of the loaders should not exclude those files. Thus, I can't add the files to an exclude for the entire rule.

Can I exclude files on a per-loader basis? If required, I'm willing to write some plugin code, though obviously out of the box would be ideal.

This is related to this Angular2 Webpack issue: (I'm trying to work around the problem) https://github.com/angular/angular-cli/issues/2730

网友答案:

While I didn't try it myself, the documentation suggests it's possible: pass the only query to babel-loader with a value of "glob, regex, or mixed array of both".

Sources: babel-loader options and Babel options Don't forget to properly format the query value as a string, so the options parser can read it.

相关阅读:
Top