@sanity/extract-text-webpack-plugin
Extract text from bundle into a file.
Last updated 3 years ago by rexxars .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @sanity/extract-text-webpack-plugin 
SYNC missed versions from official npm registry.

extract text plugin for webpack

Usage example with css

var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
	module: {
		loaders: [
			{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-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.

Advantages:

  • 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)

Caveats:

  • Additional HTTP request
  • Longer compilation time
  • More complex configuration
  • No runtime public path modification
  • No Hot Module Replacement

API

new ExtractTextPlugin([id: string], filename: string, [options])
  • id Unique ident for this plugin instance. (For advanded usage only, by default automatic generated)
  • filename 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 extract from all additional chunks too (by default it extracts only from the initial chunk(s))
    • disable disables the plugin

The ExtractTextPlugin generates an output file per entry, so you must use [name], [id] or [contenthash] when using multiple entries.

ExtractTextPlugin.extract([notExtractLoader], loader, [options])

Creates an extracting loader from an existing loader.

  • notExtractLoader (optional) the loader(s) that should be used when the css is not extracted (i.e. in an additional chunk when allChunks: false)
  • loader the loader(s) that should be used for converting the resource to a css exporting module.
  • options
    • publicPath 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.

let ExtractTextPlugin = require('extract-text-webpack-plugin');

// multiple extract instances
let extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
let 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'])},
      ...
    ]
  },
  plugins: [
    extractCSS,
    extractLESS
  ]
};

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Current Tags

  • 0.111.6-beta.0                                ...           beta (3 years ago)
  • 0.116.0-alpha.b997a667                                ...           canary (3 years ago)
  • 0.105.0-drafts.0                                ...           drafts (3 years ago)
  • 0.115.2                                ...           latest (3 years ago)
  • 0.108.0-beta.2                                ...           next (3 years ago)

66 Versions

  • 0.115.2                                ...           3 years ago
  • 0.116.0-alpha.b997a667                                ...           3 years ago
  • 0.116.0-alpha.b98ad418                                ...           3 years ago
  • 0.116.0-alpha.e2d07b9d                                ...           3 years ago
  • 0.116.0-alpha.5bbff73d                                ...           3 years ago
  • 0.116.0-alpha.d87df7bd                                ...           3 years ago
  • 0.115.0-next.06b9dcc2                                ...           3 years ago
  • 0.115.0-next.46b477e5                                ...           3 years ago
  • 0.115.0-next.0cd795cf                                ...           3 years ago
  • 0.115.0-next.10401d0e                                ...           3 years ago
  • 0.113.7                                ...           3 years ago
  • 0.113.3                                ...           3 years ago
  • 0.113.1                                ...           3 years ago
  • 0.113.0                                ...           3 years ago
  • 0.113.0-alpha.023b1989                                ...           3 years ago
  • 0.113.0-alpha.f6d0f98d                                ...           3 years ago
  • 0.112.0                                ...           3 years ago
  • 0.111.6-beta.0                                ...           3 years ago
  • 0.112.0-next.269a50ce                                ...           3 years ago
  • 0.112.0-next.95d3c914                                ...           3 years ago
  • 0.112.0-next.d745a58c                                ...           3 years ago
  • 0.112.0-next.9525798e                                ...           3 years ago
  • 0.111.5                                ...           3 years ago
  • 0.112.0-alpha.42c69838                                ...           3 years ago
  • 0.112.0-alpha.fcc45c9d                                ...           3 years ago
  • 0.112.0-alpha.c03acae3                                ...           3 years ago
  • 0.110.0-next.266637f7                                ...           3 years ago
  • 0.109.0-next.46baa731                                ...           3 years ago
  • 0.109.0-next.ee186f4b                                ...           3 years ago
  • 0.109.0-next.03e4bf11                                ...           3 years ago
  • 0.109.0-alpha.1862fd4f                                ...           3 years ago
  • 0.109.0-alpha.4a764d83                                ...           3 years ago
  • 0.109.0-alpha.17fcc625                                ...           3 years ago
  • 0.108.0                                ...           3 years ago
  • 0.108.0-beta.2                                ...           3 years ago
  • 0.108.0-beta.1                                ...           3 years ago
  • 0.107.29                                ...           3 years ago
  • 0.108.0-alpha.922a7874                                ...           3 years ago
  • 0.108.0-alpha.6e9e335c                                ...           3 years ago
  • 0.107.28-alpha.1a5051bd                                ...           3 years ago
  • 0.108.0-alpha.32abe08e                                ...           3 years ago
  • 0.108.0-alpha.d5efed6d                                ...           3 years ago
  • 0.107.27                                ...           3 years ago
  • 0.108.0-alpha.dca88d40                                ...           3 years ago
  • 0.107.25-alpha.a5f5b872                                ...           3 years ago
  • 0.107.25-alpha.6ea8df80                                ...           3 years ago
  • 0.107.25-alpha.77296ffd                                ...           3 years ago
  • 0.106.28-next                                ...           3 years ago
  • 0.106.27-next                                ...           3 years ago
  • 0.106.21                                ...           3 years ago
  • 0.106.13                                ...           3 years ago
  • 0.106.12                                ...           3 years ago
  • 0.106.10                                ...           3 years ago
  • 0.106.2                                ...           3 years ago
  • 0.105.1                                ...           3 years ago
  • 0.105.0-drafts.2                                ...           3 years ago
  • 0.105.0-drafts.0                                ...           3 years ago
  • 0.104.44                                ...           3 years ago
  • 0.104.43                                ...           3 years ago
  • 0.104.34-alpha.bddee3b4                                ...           3 years ago
  • 0.104.34-alpha.136d385a                                ...           3 years ago
  • 0.103.13                                ...           3 years ago
  • 0.103.12                                ...           3 years ago
  • 0.103.9                                ...           3 years ago
  • 0.99.5                                ...           3 years ago
  • 1.0.1                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (11)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |