1.0.1 • Published 3 years ago

capitalize-loader v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm node cover size

capitalize-loader

A capitalize loader for webpack. Just capitalize the source content.

i like skating. >>> I Like Skating.

Getting Started

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.

Options

NameTypeDefaultDescription
esModule{Boolean}trueuse ES module syntax, default as cjs
regExp{RegExp}/(^| \s+)a-z{1}/gregExp for content parse
processor{Function}nullcustom processor | (source, options)
outputPath{String}./output path
fileName{String}nulloutput filename

License

MIT