A capitalize loader for webpack. Just capitalize the source content.
i like skating. >>> I Like Skating.
To begin, you'll need to install capitalize-loader
:
npm install capitalize-loader --save-dev
Then add the loader to your webpack
config. For example:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.txt$/,
use: "capitalize-loader",
},
],
},
};
You can also provide some options
for the loader. For example:
{
test: /\.txt$/,
use: {
loader: 'capitalize-loader',
options: {
regExp: /(^|\s+|\W)[a-z]{1}/g,
outputPath: './dist',
fileName: '[name]-[contenthash:5].[ext]',
processor: (source, options) => {
return source.replace(/raw/, 'short')
}
}
}
}
And run webpack
via your preferred method.
Name | Type | Default | Description |
---|---|---|---|
esModule | {Boolean} |
true | use ES module syntax, default as cjs |
regExp | {RegExp} |
/(^| \s+)[a-z]{1}/g | regExp for content parse |
processor | {Function} |
null | custom processor | (source, options) |
outputPath | {String} |
./ | output path |
fileName | {String} |
null | output filename |