I'm trying to use strip-loader in a Typescript project built with Webpack, but not having any luck.
My ts-loader statement looks like:
{ test: /\.ts$/, loader: 'babel-loader?presets[]=es2015!ts-loader' }
...and this works fine. Typescript targets ES6 and I end up with ES5 thanks to Babel. But my code has lots of console logging using Angular's $log service, so I want to strip out lines looking like:
this.$log.log ("Some message here");
So I updated my Webpack file with:
{ test: /\.ts$/, loader: 'babel-loader?presets[]=es2015!strip-loader?strip[]=this.log!ts-loader' }
So thinking "right to left", TS generates ES6, strip-loader takes out any line beginning this.$log
and Babel takes the result and produces ES5.
But no-joy. No matter what pattern I pass to strip-loader (ie strip[]=this
), it doesn't touch the code.
What am I doing wrong?
Thanks, Jeff
You have $
in your pattern which means end of string in regex. Thy to escape it:
{ test: /\.ts$/, loader: 'babel-loader?presets[]=es2015!strip-loader?strip[]=this.\\$log.log!ts-loader' }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.