strip-whitespace-loader
Strip-Whitespace-Loader is a loader for webpack that will remove extraneous spaces from strings. It's perfect for working with rendering templates (ex. mustache, handlebars) or es6 javascript templates. It works with anything where you might create very long strings.
Before strip-whitespace-loader:
function() {
if (condition) {
const longString = ' String with some extra spaces ';
}
}
After strip-whitespace-loader:
function() {
if (condition) {
const longString = ' String with some extra spaces ';
}
}
Webpack usage
{
module: {
rules:[
{
test: /\.js$/,
loader: [ 'strip-whitespace-loader', 'babel-loader' ]
},
{
test: /\.tsx?$/,
loader: [ 'strip-whitespace-loader', 'ts-loader' ]
}
]
}
}