{"id":19908835,"url":"https://github.com/vseventer/uncss-webpack-plugin","last_synced_at":"2025-05-03T02:31:26.403Z","repository":{"id":57385835,"uuid":"83837960","full_name":"vseventer/uncss-webpack-plugin","owner":"vseventer","description":"Remove unused CSS using uncss in Webpack.","archived":false,"fork":false,"pushed_at":"2017-07-22T22:25:09.000Z","size":7,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T15:51:37.459Z","etag":null,"topics":["css","tree-shaking","uncss","webpack","webpack-plugin"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vseventer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-03T20:23:03.000Z","updated_at":"2021-04-10T18:28:09.000Z","dependencies_parsed_at":"2022-09-26T16:50:57.492Z","dependency_job_id":null,"html_url":"https://github.com/vseventer/uncss-webpack-plugin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Funcss-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Funcss-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Funcss-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vseventer%2Funcss-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vseventer","download_url":"https://codeload.github.com/vseventer/uncss-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252133709,"owners_count":21699585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","tree-shaking","uncss","webpack","webpack-plugin"],"created_at":"2024-11-12T21:13:37.146Z","updated_at":"2025-05-03T02:31:26.172Z","avatar_url":"https://github.com/vseventer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uncss-webpack-plugin\n\u003e Remove unused CSS using [uncss](https://www.npmjs.com/package/uncss) in [Webpack](https://webpack.js.org/).\n\nThis plugin is an alternative to using UnCSS with `postcss-loader`. Running UnCSS as a loader has a few drawbacks:\n* There is no way to obtain the HTML files in the pipeline, hence you can only run UnCSS against HTML files on disk.\n* Any references to JavaScript files in the pipeline causes errors, for the same reason as above.\n\nBy running UnCSS as plugin, after all assets are loaded, we can overcome the two drawbacks outlined above. However, because Webpack holds its assets in memory until the very last stage, this plugin uses some ugly patching of [jsdom](https://www.npmjs.com/package/jsdom), the underlying mechanism used by UnCSS. The benefit, however, is that UnCSS supports any selectors dynamically added by JavaScript, and the final output will be correct.\n\n*NOTE: Your HTML and CSS files must be extracted from the bundle, otherwise this plugin will not work. For HTML, you can use `[ 'file-loader', 'extract-loader', 'html-loader' ]`, while for CSS `[ 'file-loader', 'extract-loader', 'css-loader' ]` will do the trick.*\n\n## Install\n`npm install uncss-webpack-plugin`\n\n## Usage\nThis plugin is designed for Webpack 2. Load the plugin, and simply add it to the plugin entry in your `webpack.config.js`.\n\n```js\n// Package modules.\nconst UnCSSPlugin = require('uncss-webpack-plugin');\n\n// Exports.\nmodule.exports = {\n  ...\n  plugins: [\n    new UnCSSPlugin({ /* options */ })\n  ]\n}\n```\n\n### Options\nFor more detailed information, please refer to the [UnCSS Usage section](https://www.npmjs.com/package/uncss#usage). Because Webpack controls the CSS, the following options are ignored: `csspath`, `ignoreSheets`, `media`, `raw`, `report`, and `stylesheets`.\n\n* **enable** (boolean, default `true`) - enable the plugin.\n* **html** (array, default to Webpack HTML assets) - list of HTML files to check.\n* **htmlroot** (string) - where the project root is.\n* **timeout** (number) - specify how long to wait for the JS to be loaded.\n* **uncssrc** (string) - load all options from a JSON file.\n\n## Changelog\nSee the [CHANGELOG](./CHANGELOG.md) for a list of changes.\n\n## License\n    The MIT License (MIT)\n\n    Copyright (c) 2017 Mark van Seventer\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy of\n    this software and associated documentation files (the \"Software\"), to deal in\n    the Software without restriction, including without limitation the rights to\n    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\n    the Software, and to permit persons to whom the Software is furnished to do so,\n    subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\n    FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\n    COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\n    IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\n    CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvseventer%2Funcss-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvseventer%2Funcss-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvseventer%2Funcss-webpack-plugin/lists"}