Skip to content

qinhua/capitalize-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

capitalize-loader

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

npm npm coverage size

Getting Started

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.

Options

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

License

MIT

About

A capitalize loader for webpack.

Resources

License

Stars

Watchers

Forks

Packages

No packages published