|
| 1 | +# purgecss-webpack-plugin |
| 2 | +<!-- [](https://travis-ci.org/FullHuman/purgecss-webpack-plugin) |
| 3 | +[]() --> |
| 4 | +[](https://david-dm.org/fullhuman/purgecss-webpack-plugin) |
| 5 | +[](https://david-dm.org/fullhuman/purgecss-webpack-plugin?type=dev) |
| 6 | + |
| 7 | +[Webpack](https://github.com/webpack/webpack) plugin to remove unused css. |
| 8 | + |
| 9 | +## Install |
| 10 | + |
| 11 | +```sh |
| 12 | +npm i purgecss-webpack-plugin -D |
| 13 | +``` |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +```js |
| 18 | +const path = require('path') |
| 19 | +const glob = require('glob') |
| 20 | +const ExtractTextPlugin = require('extract-text-webpack-plugin') |
| 21 | +const PurgecssPlugin = require('../../') |
| 22 | + |
| 23 | +const PATHS = { |
| 24 | + src: path.join(__dirname, 'src') |
| 25 | +} |
| 26 | + |
| 27 | +module.exports = { |
| 28 | + entry: './src/index.js', |
| 29 | + output: { |
| 30 | + filename: 'bundle.js', |
| 31 | + path: path.join(__dirname, 'dist') |
| 32 | + }, |
| 33 | + module: { |
| 34 | + rules: [ |
| 35 | + { |
| 36 | + test: /\.css$/, |
| 37 | + use: ExtractTextPlugin.extract({ |
| 38 | + fallback: 'style-loader', |
| 39 | + use: 'css-loader?sourceMap' |
| 40 | + }) |
| 41 | + } |
| 42 | + ] |
| 43 | + }, |
| 44 | + plugins: [ |
| 45 | + new ExtractTextPlugin('[name].css?[hash]'), |
| 46 | + new PurgecssPlugin({ |
| 47 | + paths: glob.sync(`${PATHS.src}/*`), |
| 48 | + styleExtensions: ['.css'] |
| 49 | + }) |
| 50 | + ] |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +## Contributing |
| 55 | + |
| 56 | +Please read [CONTRIBUTING.md](./.github/CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us. |
| 57 | + |
| 58 | +## Versioning |
| 59 | + |
| 60 | +We use [SemVer](http://semver.org/) for versioning. |
| 61 | + |
| 62 | + |
| 63 | +## Acknowledgment |
| 64 | + |
| 65 | +Purgecss was originally thought as the v2 of purifycss. And because of it, it is greatly inspired by it. |
| 66 | +The plugins such as purgecss-webpack-plugin are based on the purifycss plugin. |
| 67 | +Below is the list of the purifycss repositories: |
| 68 | +- [purifycss](https://github.com/purifycss/purifycss) |
| 69 | +- [gulp-purifycss](https://github.com/purifycss/gulp-purifycss) |
| 70 | +- [purifycss-webpack](https://github.com/webpack-contrib/purifycss-webpack) |
| 71 | + |
| 72 | +## License |
| 73 | + |
| 74 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details |
| 75 | + |
0 commit comments