Socket
Socket
Sign inDemoInstall

extract-text-webpack-plugin

Package Overview
Dependencies
277
Maintainers
7
Versions
56
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0-beta.5 to 2.0.0-rc.0

.github/ISSUE_TEMPLATE.md

0

ExtractedModule.js

@@ -0,0 +0,0 @@ /*

18

index.js

@@ -131,8 +131,7 @@ /*

// modified from webpack/lib/LoadersList.js
function getLoaderWithQuery(loader) {
if(isString(loader)) return loader;
if(!loader.query) return loader.loader;
var query = isString(loader.query) ? loader.query : JSON.stringify(loader.query);
return loader.loader + "?" + query;
function getLoaderObject(loader) {
if (isString(loader)) {
return {loader: loader};
}
return loader;
}

@@ -153,3 +152,3 @@

ExtractTextPlugin.loader = function(options) {
return { loader: require.resolve("./loader"), query: options };
return { loader: require.resolve("./loader"), options: options };
};

@@ -185,3 +184,3 @@

}
if(Array.isArray(options) || isString(options) || typeof options.query === "object") {
if(Array.isArray(options) || isString(options) || typeof options.options === "object" || typeof options.query === 'object') {
options = { loader: options };

@@ -204,4 +203,3 @@ }

.concat(before, loader)
.map(getLoaderWithQuery)
.join("!");
.map(getLoaderObject);
}

@@ -208,0 +206,0 @@

@@ -0,0 +0,0 @@ /*

@@ -0,0 +0,0 @@ /*

{
"name": "extract-text-webpack-plugin",
"version": "2.0.0-beta.5",
"version": "2.0.0-rc.0",
"author": "Tobias Koppers @sokra",
"description": "Extract text from bundle into a file.",
"engines": {
"node": ">=4.3.0 < 5.0.0 || >= 5.10"
},
"peerDependencies": {
"webpack": "^2.1.0-beta.19 || ^2.2.0-rc.0"
"webpack": "^2.2.0"
},

@@ -17,11 +20,12 @@ "dependencies": {

"coveralls": "^2.11.2",
"css-loader": "^0.21.0",
"file-loader": "^0.8.4",
"istanbul": "^0.3.13",
"mocha": "^2.3.3",
"mocha-lcov-reporter": "0.0.2",
"css-loader": "^0.26.1",
"file-loader": "^0.9.0",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"mocha-lcov-reporter": "1.2.0",
"raw-loader": "^0.5.1",
"should": "^7.1.1",
"should": "^11.1.2",
"standard-version": "^4.0.0",
"style-loader": "^0.13.0",
"webpack": "^2.1.0-beta"
"webpack": "^2.2.0"
},

@@ -38,4 +42,4 @@ "homepage": "http://github.com/webpack/extract-text-webpack-plugin",

"cover": "istanbul cover _mocha",
"publish-patch": "mocha && npm version patch && git push && git push --tags && npm publish"
"release": "standard-version"
}
}

@@ -1,71 +0,81 @@

# extract text plugin for webpack 2
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
The API has changed since version 1. For the webpack 1 version, see [the README in the webpack-1 branch](https://github.com/webpack/extract-text-webpack-plugin/blob/webpack-1/README.md).
<div align="center">
<img width="200" height="200"
src="https://webpack.github.io/extract-text-webpack-plugin/logo.svg">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200"
src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
<h1>Extract Text Plugin</h1>
</div>
## Install
<h2 align="center">Install</h2>
> You can either install it with [npm](https://nodejs.org/en/) or [yarn](https://yarnpkg.com/)
```sh
```bash
npm install --save-dev extract-text-webpack-plugin
```
or
```sh
yarn add --dev extract-text-webpack-plugin
```
## Usage example with css
<h2 align="center">Usage</h2>
``` javascript
var ExtractTextPlugin = require("extract-text-webpack-plugin");
> :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).
```js
const ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
module: {
loaders: [
{ test: /\.css$/, loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader"
}) }
]
},
plugins: [
new ExtractTextPlugin("styles.css")
]
module: {
rules: [
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallbackLoader: "style-loader",
loader: "css-loader"
})
}
]
},
plugins: [
new ExtractTextPlugin("styles.css");
]
}
```
It moves every `require("style.css")` in entry chunks into a separate css output file. So your styles are no longer inlined into the javascript, but separate in a css bundle file (`styles.css`). If your total stylesheet volume is big, it will be faster because the stylesheet bundle is loaded in parallel to the javascript bundle.
It moves every `require("style.css")` in entry chunks into a separate CSS file. So your styles are no longer inlined into the JS bundle, but separate in a CSS bundle 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.
Advantages:
|Advantages|Caveats|
|:---------|:------|
| Fewer style tags (older IE has a limit) | Additional HTTP request |
| CSS SourceMap (with `devtool: "source-map"` and `extract-text-webpack-plugin?sourceMap`) | Longer compilation time |
| CSS requested in parallel | No runtime public path modification |
| CSS cached separate | No Hot Module Replacement |
| Faster runtime (less code and DOM operations) | ... |
* Fewer style tags (older IE has a limit)
* CSS SourceMap (with `devtool: "source-map"` and `css-loader?sourceMap`)
* CSS requested in parallel
* CSS cached separate
* Faster runtime (less code and DOM operations)
<h2 align="center">Options</h2>
Caveats:
```js
new ExtractTextPlugin(options: filename | object)
```
* Additional HTTP request
* Longer compilation time
* More complex configuration
* No runtime public path modification
* No Hot Module Replacement
|Name|Type|Description|
|:--:|:--:|:----------|
|**`id`**|`{String}`|Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)|
|**`filename`**|`{String}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`|
|**`options.allChunks`**|`{Boolean}`|Extract from all additional chunks too (by default it extracts only from the initial chunk(s))|
|**`options.disable`**|`{Boolean}`|Disables the plugin|
## API
* `[name]` name of the chunk
* `[id]` number of the chunk
* `[contenthash]` hash of the content of the extracted file
``` javascript
new ExtractTextPlugin(options: filename | object)
```
> :warning: `ExtractTextPlugin` generates a file **per entry**, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.
* `options.filename: string` _(required)_ the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]`
* `[name]` the name of the chunk
* `[id]` the number of the chunk
* `[contenthash]` a hash of the content of the extracted file
* `options.allChunks: boolean` extract from all additional chunks too (by default it extracts only from the initial chunk(s))
* `options.disable: boolean` disables the plugin
* `options.id: string` Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)
#### `#extract`
The `ExtractTextPlugin` generates an output file per entry, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.
``` javascript
```js
ExtractTextPlugin.extract(options: loader | object)

@@ -76,22 +86,31 @@ ```

* `options.loader: string | object | loader[]` _(required)_ the loader(s) that should be used for converting the resource to a css exporting module
* `options.fallbackLoader: string | object | loader[]` the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when `allChunks: false`)
* `options.publicPath: string` override the `publicPath` setting for this loader
|Name|Type|Description|
|:--:|:--:|:----------|
|**`options.loader`**|`{String}`/`{Object}`|Loader(s) that should be used for converting the resource to a CSS exporting module _(required)_|
|**`options.fallbackLoader`**|`{String}`/`{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`)|
|**`options.publicPath`**|`{String}`|Override the `publicPath` setting for this loader|
There is also an `extract` function on the instance. You should use this if you have more than one `ExtractTextPlugin`.
```javascript
let ExtractTextPlugin = require('extract-text-webpack-plugin');
#### Multiple Instances
// multiple extract instances
let extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
let extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
There is also an `extract` function on the instance. You should use this if you have more than one instance of `ExtractTextPlugin`.
```js
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// Create multiple instances
const extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
const extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
module.exports = {
...
module: {
loaders: [
{ test: /\.scss$/i, loader: extractCSS.extract(['css','sass']) },
{ test: /\.less$/i, loader: extractLESS.extract(['css','less']) },
...
use: [
{
test: /\.css$/,
loader: extractCSS.extract([ 'css-loader', 'postcss-loader' ])
},
{
test: /\.html$/i,
loader: extractLESS.extract([ 'css-loader', 'less-loader' ])
},
]

@@ -106,4 +125,33 @@ },

## License
<h2 align="center">Maintainer</h2>
MIT (http://www.opensource.org/licenses/mit-license.php)
<table>
<tbody>
<tr>
<td align="center">
<img width="150 height="150" src="https://github.com/sokra.png?s=150">
<br>
<a href="https://github.com/sokra">Tobias Koppers</a>
</td>
<tr>
<tbody>
</table>
[npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg
[npm-url]: https://npmjs.com/package/extract-text-webpack-plugin
[node]: https://img.shields.io/node/v/extract-text-webpack-plugin.svg
[node-url]: https://nodejs.org
[deps]: https://david-dm.org/webpack/extract-text-webpack-plugin.svg
[deps-url]: https://david-dm.org/webpack/extract-text-webpack-plugin
[tests]: http://img.shields.io/travis/webpack/extract-text-webpack-plugin.svg
[tests-url]: https://travis-ci.org/webpack/extract-text-webpack-plugin
[cover]: https://coveralls.io/repos/github/webpack/extract-text-webpack-plugin/badge.svg
[cover-url]: https://coveralls.io/github/webpack/extract-text-webpack-plugin
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc