{"id":13659454,"url":"https://github.com/lukeed/webpack-critical","last_synced_at":"2025-10-09T18:23:43.368Z","repository":{"id":53843771,"uuid":"103318550","full_name":"lukeed/webpack-critical","owner":"lukeed","description":"Extracts \u0026 inlines Critical CSS with Wepack","archived":false,"fork":false,"pushed_at":"2017-12-13T20:34:15.000Z","size":8,"stargazers_count":109,"open_issues_count":3,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-11T06:49:38.436Z","etag":null,"topics":[],"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/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-12T20:41:36.000Z","updated_at":"2024-05-20T11:10:02.000Z","dependencies_parsed_at":"2022-08-23T05:50:17.859Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/webpack-critical","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/lukeed%2Fwebpack-critical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-critical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-critical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fwebpack-critical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/webpack-critical/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250643727,"owners_count":21464226,"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":[],"created_at":"2024-08-02T05:01:08.893Z","updated_at":"2025-10-09T18:23:38.337Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# webpack-critical\n\n\u003e Extracts \u0026 inlines Critical CSS with Webpack\n\n\n## Install\n\n```\n$ npm install webpack-critical --save-dev\n```\n\n\u003e **Important:** You _must_ also install \u0026 configure [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin)!\n\n\n## Usage\n\n```js\n// webpack.config.js\nconst { resolve } = require('path');\nconst HTML = require('html-webpack-plugin');\nconst WebpackCritical = require('webpack-critical');\n\nconst dist = resolve('build');\n\nmodule.exports = {\n  output: {\n    path: dist\n  },\n  // ...\n  plugins: [\n    new HTML({ ... })\n    new WebpackCritical({\n      context: dist,\n      ignore: [/bootstrap/, '@font-face']\n    })\n  ]\n}\n```\n\n\n## API\n\n### WebpackCritical(options)\n\n#### options.context\n\nType: `String`\u003cbr\u003e\nDefault: `process.cwd()`\n\nThe directory context to search for your (built) stylesheet.\n\n\u003e **Note:** In most cases, this should match your `output.path` value.\n\n#### options.ignore\n\nType: `String`, `RegExp`, `Function`, or `Array`\u003cbr\u003e\nDefault: `['@font-face', /import/, /url\\(/]`\n\nPatterns to ignore CSS styles or files. Refer to [`filter-css`](https://github.com/bezoerb/filter-css#pattern) for more information.\n\n#### options.stylesheet\n\nType: `String`\u003cbr\u003e\nDefault: `null`\n\nThe filename or filepath (relative to `context`) of a specific CSS stylesheet to use for inlining.\n\nIf no value is passed, the primary CSS asset is used (as determined by [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin)). If you are [extracting a stylesheet](https://github.com/webpack-contrib/extract-text-webpack-plugin#usage), this will be the correct value _99%_ of the time.\n\n\n## Credit\n\nInspired by [Dan Denny](https://github.com/dandenney)'s article on [Building a Small PWA with Preact and Firebase](https://dandenney.com/posts/front-end-dev/building-a-small-pwa-with-preact-and-firebase), which lead me to take a much closer look at [`critical`](https://github.com/addyosmani/critical), maintained by [Addy Osmani](https://github.com/addyosmani) and [Ben Zörb](https://github.com/bezoerb).\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwebpack-critical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fwebpack-critical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fwebpack-critical/lists"}