An open API service indexing awesome lists of open source software.

https://github.com/peterroe/count-webpack-plugin

Count the number of chars in file.
https://github.com/peterroe/count-webpack-plugin

plugin webpack

Last synced: 11 months ago
JSON representation

Count the number of chars in file.

Awesome Lists containing this project

README

          

## What is it?

A example of plugin of [`webpack`](https://webpack.js.org), and it's used to count the number of chars in file.

## Core Code

```js
class CountWebpackPlugin {
apply(compiler) {
compiler.hooks.emit.tap('CountWebpackPlugin', (
compilation
) => {
let str = ''
for (let filename in compilation.assets) {
const { _value } = compilation.assets[filename]
str += `Number of chars in \`${filename}\`: \`${_value.length}\` \n`
}
//write file
compilation.assets['fileSize.md'] = {
source() {
return str
}
}
})
}
}

module.exports = CountWebpackPlugin;
```