{"id":13475269,"url":"https://github.com/webpack-contrib/extract-text-webpack-plugin","last_synced_at":"2025-10-05T18:31:14.500Z","repository":{"id":13604782,"uuid":"16297741","full_name":"webpack-contrib/extract-text-webpack-plugin","owner":"webpack-contrib","description":"[DEPRECATED] Please use https://github.com/webpack-contrib/mini-css-extract-plugin Extracts text from a bundle into a separate file","archived":true,"fork":false,"pushed_at":"2019-05-29T11:48:46.000Z","size":779,"stargazers_count":4010,"open_issues_count":0,"forks_count":511,"subscribers_count":100,"default_branch":"master","last_synced_at":"2025-01-15T20:40:51.968Z","etag":null,"topics":["webpack-plugin"],"latest_commit_sha":null,"homepage":"","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/webpack-contrib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-01-28T00:28:36.000Z","updated_at":"2024-12-27T00:47:19.000Z","dependencies_parsed_at":"2022-08-07T07:15:37.679Z","dependency_job_id":null,"html_url":"https://github.com/webpack-contrib/extract-text-webpack-plugin","commit_stats":null,"previous_names":["webpack/extract-text-webpack-plugin"],"tags_count":46,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fextract-text-webpack-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fextract-text-webpack-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fextract-text-webpack-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webpack-contrib%2Fextract-text-webpack-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webpack-contrib","download_url":"https://codeload.github.com/webpack-contrib/extract-text-webpack-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235432168,"owners_count":18989468,"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":["webpack-plugin"],"created_at":"2024-07-31T16:01:18.871Z","updated_at":"2025-10-05T18:31:07.110Z","avatar_url":"https://github.com/webpack-contrib.png","language":"JavaScript","readme":"# DEPRECATED\n\nPlease use: https://github.com/webpack-contrib/mini-css-extract-plugin\n\nIf you have problem(s) with migration on MiniCssExtractPlugin feel free to open issue with reproducible test repo, thanks\n\n---\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"200\" height=\"200\"\n    src=\"https://cdn.rawgit.com/webpack-contrib/extract-text-webpack-plugin/574e3200/logo.svg\"\u003e\n  \u003ca href=\"https://github.com/webpack/webpack\"\u003e\n    \u003cimg width=\"200\" height=\"200\"\n      src=\"https://webpack.js.org/assets/icon-square-big.svg\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003eExtract Text Plugin\u003c/h1\u003e\n  \u003cp\u003eExtract text from a bundle, or bundles, into a separate file.\u003c/p\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\n# for webpack 3\nnpm install --save-dev extract-text-webpack-plugin\n# for webpack 2\nnpm install --save-dev extract-text-webpack-plugin@2.1.2\n# for webpack 1\nnpm install --save-dev extract-text-webpack-plugin@1.0.1\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n\u003e :warning: Since webpack v4 the `extract-text-webpack-plugin` should not be used for css. Use [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) instead.\n\n\u003e :warning: For webpack v1, see [the README in the webpack-1 branch](https://github.com/webpack/extract-text-webpack-plugin/blob/webpack-1/README.md).\n\n```js\nconst ExtractTextPlugin = require(\"extract-text-webpack-plugin\");\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: ExtractTextPlugin.extract({\n          fallback: \"style-loader\",\n          use: \"css-loader\"\n        })\n      }\n    ]\n  },\n  plugins: [\n    new ExtractTextPlugin(\"styles.css\"),\n  ]\n}\n```\n\nIt moves all the required `*.css` modules in entry chunks into a separate CSS file. So your styles are no longer inlined into the JS bundle, but in a separate CSS file (`styles.css`). If your total stylesheet volume is big, it will be faster because the CSS bundle is loaded in parallel to the JS bundle.\n\n|Advantages|Caveats|\n|:---------|:------|\n| Fewer style tags (older IE has a limit) | Additional HTTP request |\n| CSS SourceMap (with `devtool: \"source-map\"` and `extract-text-webpack-plugin?sourceMap`) | Longer compilation time |\n| CSS requested in parallel | No runtime public path modification |\n| CSS cached separate | No Hot Module Replacement |\n| Faster runtime (less code and DOM operations) | ... |\n\n\u003ch2 align=\"center\"\u003eOptions\u003c/h2\u003e\n\n```js\nnew ExtractTextPlugin(options: filename | object)\n```\n\n|Name|Type|Description|\n|:--:|:--:|:----------|\n|**`id`**|`{String}`|Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)|\n|**`filename`**|`{String\\|Function}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`|\n|**`allChunks`**|`{Boolean}`|Extract from all additional chunks too (by default it extracts only from the initial chunk(s))\u003cbr /\u003eWhen using `CommonsChunkPlugin` and there are extracted chunks (from `ExtractTextPlugin.extract`) in the commons chunk, `allChunks` **must** be set to `true`|\n|**`disable`**|`{Boolean}`|Disables the plugin|\n|**`ignoreOrder`**|`{Boolean}`|Disables order check (useful for CSS Modules!), `false` by default|\n\n* `[name]` name of the chunk\n* `[id]` number of the chunk\n* `[contenthash]` hash of the content of the extracted file\n* `[\u003chashType\u003e:contenthash:\u003cdigestType\u003e:\u003clength\u003e]` optionally you can configure\n  * other `hashType`s, e.g. `sha1`, `md5`, `sha256`, `sha512`\n  * other `digestType`s, e.g. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`\n  * and `length`, the length of the hash in chars\n\n\u003e :warning: `ExtractTextPlugin` generates a file **per entry**, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.\n\n#### `#extract`\n\n```js\nExtractTextPlugin.extract(options: loader | object)\n```\n\nCreates an extracting loader from an existing loader. Supports loaders of type `{ loader: [name]-loader -\u003e {String}, options: {} -\u003e {Object} }`.\n\n|Name|Type|Description|\n|:--:|:--:|:----------|\n|**`options.use`**|`{String}`/`{Array}`/`{Object}`|Loader(s) that should be used for converting the resource to a CSS exporting module _(required)_|\n|**`options.fallback`**|`{String}`/`{Array}`/`{Object}`|loader(e.g `'style-loader'`) that should be used when the CSS is not extracted (i.e. in an additional chunk when `allChunks: false`)|\n|**`options.publicPath`**|`{String}`|Override the `publicPath` setting for this loader|\n\n\n#### Multiple Instances\n\nThere is also an `extract` function on the instance. You should use this if you have more than one instance of  `ExtractTextPlugin`.\n\n```js\nconst ExtractTextPlugin = require('extract-text-webpack-plugin');\n\n// Create multiple instances\nconst extractCSS = new ExtractTextPlugin('stylesheets/[name]-one.css');\nconst extractLESS = new ExtractTextPlugin('stylesheets/[name]-two.css');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.css$/,\n        use: extractCSS.extract([ 'css-loader', 'postcss-loader' ])\n      },\n      {\n        test: /\\.less$/i,\n        use: extractLESS.extract([ 'css-loader', 'less-loader' ])\n      },\n    ]\n  },\n  plugins: [\n    extractCSS,\n    extractLESS\n  ]\n};\n```\n\n### Extracting Sass or LESS\n\nThe configuration is the same, switch out `sass-loader` for `less-loader` when necessary.\n\n```js\nconst ExtractTextPlugin = require('extract-text-webpack-plugin');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.scss$/,\n        use: ExtractTextPlugin.extract({\n          fallback: 'style-loader',\n          use: ['css-loader', 'sass-loader']\n        })\n      }\n    ]\n  },\n  plugins: [\n    new ExtractTextPlugin('style.css')\n    //if you want to pass in options, you can do so:\n    //new ExtractTextPlugin({\n    //  filename: 'style.css'\n    //})\n  ]\n}\n```\n\n### `url()` Resolving\n\nIf you are finding that urls are not resolving properly when you run webpack. You can expand your loader functionality with options. The `url: false` property allows your paths resolved without any changes.\n\n```js\nconst ExtractTextPlugin = require('extract-text-webpack-plugin');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.scss$/,\n        use: ExtractTextPlugin.extract({\n          fallback: 'style-loader',\n          use: [\n            {\n                loader: 'css-loader',\n                options: {\n                    // If you are having trouble with urls not resolving add this setting.\n                    // See https://github.com/webpack-contrib/css-loader#url\n                    url: false,\n                    minimize: true,\n                    sourceMap: true\n                }\n            }, \n            {\n                loader: 'sass-loader',\n                options: {\n                    sourceMap: true\n                }\n            }\n          ]\n        })\n      }\n    ]\n  }\n}\n```\n\n### Modify filename\n\n`filename` parameter could be `Function`. It passes `getPath` to process the format like `css/[name].css` and returns the real file name, `css/js/a.css`. You can replace `css/js` with `css` then you will get the new path `css/a.css`.\n\n\n```js\nentry: {\n  'js/a': \"./a\"\n},\nplugins: [\n  new ExtractTextPlugin({\n    filename:  (getPath) =\u003e {\n      return getPath('css/[name].css').replace('css/js', 'css');\n    },\n    allChunks: true\n  })\n]\n```\n\n\u003ch2 align=\"center\"\u003eMaintainers\u003c/h2\u003e\n\n\u003ctable\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/166921?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/bebraw\"\u003eJuho Vepsäläinen\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars2.githubusercontent.com/u/8420490?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/d3viant0ne\"\u003eJoshua Wiens\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/533616?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/SpaceK33z\"\u003eKees Kluskens\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003cimg width=\"150\" height=\"150\"\n        src=\"https://avatars3.githubusercontent.com/u/3408176?v=3\u0026s=150\"\u003e\n        \u003c/br\u003e\n        \u003ca href=\"https://github.com/TheLarkInn\"\u003eSean Larkin\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003ctbody\u003e\n\u003c/table\u003e\n\n\n[npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg\n[npm-url]: https://npmjs.com/package/extract-text-webpack-plugin\n\n[node]: https://img.shields.io/node/v/extract-text-webpack-plugin.svg\n[node-url]: https://nodejs.org\n\n[deps]: https://david-dm.org/webpack-contrib/extract-text-webpack-plugin.svg\n[deps-url]: https://david-dm.org/webpack-contrib/extract-text-webpack-plugin\n\n[tests]: http://img.shields.io/travis/webpack-contrib/extract-text-webpack-plugin.svg\n[tests-url]: https://travis-ci.org/webpack-contrib/extract-text-webpack-plugin\n\n[cover]: https://coveralls.io/repos/github/webpack-contrib/extract-text-webpack-plugin/badge.svg\n[cover-url]: https://coveralls.io/github/webpack-contrib/extract-text-webpack-plugin\n\n[chat]: https://badges.gitter.im/webpack/webpack.svg\n[chat-url]: https://gitter.im/webpack/webpack\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fextract-text-webpack-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebpack-contrib%2Fextract-text-webpack-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebpack-contrib%2Fextract-text-webpack-plugin/lists"}