Skip to content

Commit e68b4d9

Browse files
committed
resolve conflict
2 parents 454e0b9 + b755a1f commit e68b4d9

29 files changed

+691
-126
lines changed

.github/ISSUE_TEMPLATE.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
1. Check the version of package you are using. If it's not the newest version, update and try again (see changelog while updating!).
2+
2. If the issue is still there, write a minimal project showing the problem and expected output.
3+
3. Link to the project and mention Node version and OS in your report.
4+
5+
**IMPORTANT! You should use [Stack Overflow](https://stackoverflow.com/) for support related questions.**

.github/PULL_REQUEST_TEMPLATE.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. [Read and sign the CLA](https://cla.js.foundation/webpack/webpack.js.org). This needs to be done only once. PRs that haven't signed it won't be accepted.
2+
2. Check out the [development guide](https://webpack.js.org/development/) for the API and development guidelines.
3+
3. Read through the PR diff carefully as sometimes this can reveal issues. The work will be reviewed, but this can save some effort.
4+
4. Remove these instructions from your PR as they are for your eyes only.

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- "4"
54
- node
5+
- 6
6+
- 4
67
script: npm run travis
78

89
after_success:

CHANGELOG.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
<a name="2.0.0-rc.2"></a>
6+
# [2.0.0-rc.2](https://github.com/webpack/extract-text-webpack-plugin/compare/v2.0.0-rc.1...v2.0.0-rc.2) (2017-01-28)
7+
8+
9+
### Bug Fixes
10+
11+
* **schema:** allow `extract` to accept omit/remove flags ([8ce93d5](https://github.com/webpack/extract-text-webpack-plugin/commit/8ce93d5)), closes [#371](https://github.com/webpack/extract-text-webpack-plugin/issues/371)
12+
* **schema:** connect loader schema with the code properly ([03bb4aa](https://github.com/webpack/extract-text-webpack-plugin/commit/03bb4aa))
13+
* **schema:** emit proper error messages ([70cbd4b](https://github.com/webpack/extract-text-webpack-plugin/commit/70cbd4b))
14+
15+
16+
### Features
17+
18+
* **errors:** show nicer errors if there are extra fields ([76a171d](https://github.com/webpack/extract-text-webpack-plugin/commit/76a171d))
19+
20+
21+
22+
<a name="2.0.0-rc.1"></a>
23+
# [2.0.0-rc.1](https://github.com/webpack/extract-text-webpack-plugin/compare/v2.0.0-rc.0...v2.0.0-rc.1) (2017-01-28)
24+
25+
26+
### Bug Fixes
27+
28+
* **options:** pass proper loader options to children ([#266](https://github.com/webpack/extract-text-webpack-plugin/issues/266)) ([6abf42d](https://github.com/webpack/extract-text-webpack-plugin/commit/6abf42d))
29+
30+
31+
32+
<a name="2.0.0-rc.0"></a>
33+
# [2.0.0-rc.0](https://github.com/webpack/extract-text-webpack-plugin/compare/v2.0.0-beta.5...v2.0.0-rc.0) (2017-01-26)
34+
35+
36+
### Bug Fixes
37+
38+
* **readme:** Incorrect loader configuration ([e477cc7](https://github.com/webpack/extract-text-webpack-plugin/commit/e477cc7))
39+
40+
41+
### Features
42+
43+
* **extract:** return an array of loader objects ([#343](https://github.com/webpack/extract-text-webpack-plugin/issues/343)) ([74b86e0](https://github.com/webpack/extract-text-webpack-plugin/commit/74b86e0))
44+
45+
46+
47+
# Change Log
48+
49+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

ExtractedModule.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ ExtractedModule.prototype.addChunk = function(chunk) {
2727
this.chunks.push(chunk);
2828
};
2929

30-
ExtractedModule.prototype._removeAndDo = require("webpack/lib/removeAndDo");
31-
3230
ExtractedModule.prototype.removeChunk = function(chunk) {
33-
return this._removeAndDo("chunks", chunk, "removeModule");
31+
var idx = this.chunks.indexOf(chunk);
32+
if(idx >= 0) {
33+
this.chunks.splice(idx, 1);
34+
chunk.removeModule(this);
35+
return true;
36+
}
37+
return false;
3438
};
3539

3640
ExtractedModule.prototype.rewriteChunkInReasons = function(oldChunk, newChunks) { };

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright JS Foundation and other contributors
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
'Software'), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+152-82
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,121 @@
1-
# extract text plugin for webpack 2
2-
3-
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).
4-
5-
## Install
6-
7-
> You can either install it with [npm](https://nodejs.org/en/) or [yarn](https://yarnpkg.com/)
8-
9-
```sh
1+
[![npm][npm]][npm-url]
2+
[![node][node]][node-url]
3+
[![deps][deps]][deps-url]
4+
[![tests][tests]][tests-url]
5+
[![coverage][cover]][cover-url]
6+
[![chat][chat]][chat-url]
7+
8+
<div align="center">
9+
<img width="200" height="200"
10+
src="https://cdn.rawgit.com/webpack-contrib/extract-text-webpack-plugin/574e3200/logo.svg">
11+
<a href="https://github.com/webpack/webpack">
12+
<img width="200" height="200"
13+
src="https://webpack.js.org/assets/icon-square-big.svg">
14+
</a>
15+
<h1>Extract Text Plugin</h1>
16+
</div>
17+
18+
<h2 align="center">Install</h2>
19+
20+
```bash
21+
# for webpack 1
1022
npm install --save-dev extract-text-webpack-plugin
11-
```
12-
or
13-
```sh
14-
yarn add --dev extract-text-webpack-plugin
23+
# for webpack 2
24+
npm install --save-dev extract-text-webpack-plugin@beta
1525
```
1626

17-
## Usage example with css
27+
<h2 align="center">Usage</h2>
28+
29+
> :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).
30+
31+
```js
32+
const ExtractTextPlugin = require("extract-text-webpack-plugin");
1833

19-
``` javascript
20-
var ExtractTextPlugin = require("extract-text-webpack-plugin");
2134
module.exports = {
22-
module: {
23-
loaders: [
24-
{ test: /\.css$/, loader: ExtractTextPlugin.extract({
25-
fallbackLoader: "style-loader",
26-
loader: "css-loader"
27-
}) }
28-
]
29-
},
30-
plugins: [
31-
new ExtractTextPlugin("styles.css")
32-
]
35+
module: {
36+
rules: [
37+
{
38+
test: /\.css$/,
39+
use: ExtractTextPlugin.extract({
40+
fallback: "style-loader",
41+
use: "css-loader"
42+
})
43+
}
44+
]
45+
},
46+
plugins: [
47+
new ExtractTextPlugin("styles.css"),
48+
]
3349
}
3450
```
3551

36-
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.
37-
38-
Advantages:
39-
40-
* Fewer style tags (older IE has a limit)
41-
* CSS SourceMap (with `devtool: "source-map"` and `css-loader?sourceMap`)
42-
* CSS requested in parallel
43-
* CSS cached separate
44-
* Faster runtime (less code and DOM operations)
45-
46-
Caveats:
52+
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.
4753

48-
* Additional HTTP request
49-
* Longer compilation time
50-
* More complex configuration
51-
* No runtime public path modification
52-
* No Hot Module Replacement
54+
|Advantages|Caveats|
55+
|:---------|:------|
56+
| Fewer style tags (older IE has a limit) | Additional HTTP request |
57+
| CSS SourceMap (with `devtool: "source-map"` and `extract-text-webpack-plugin?sourceMap`) | Longer compilation time |
58+
| CSS requested in parallel | No runtime public path modification |
59+
| CSS cached separate | No Hot Module Replacement |
60+
| Faster runtime (less code and DOM operations) | ... |
5361

54-
## API
62+
<h2 align="center">Options</h2>
5563

56-
``` javascript
64+
```js
5765
new ExtractTextPlugin(options: filename | object)
5866
```
5967

60-
* `options.filename: string` _(required)_ the filename of the result file. May contain `[name]`, `[id]` and `[contenthash]`
61-
* `[name]` the name of the chunk
62-
* `[id]` the number of the chunk
63-
* `[contenthash]` a hash of the content of the extracted file
64-
* `options.allChunks: boolean` extract from all additional chunks too (by default it extracts only from the initial chunk(s))
65-
* `options.disable: boolean` disables the plugin
66-
* `options.id: string` Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)
67-
* `filenamefilter` function to modify path and filename before files are emitted
68-
``` javascript
69-
{
70-
filenamefilter: function(filename) {
71-
// modify filename
72-
return filename;
73-
}
74-
}
75-
```
68+
|Name|Type|Description|
69+
|:--:|:--:|:----------|
70+
|**`id`**|`{String}`|Unique ident for this plugin instance. (For advanced usage only, by default automatically generated)|
71+
|**`filename`**|`{String}`|Name of the result file. May contain `[name]`, `[id]` and `[contenthash]`|
72+
|**`allChunks`**|`{Boolean}`|Extract from all additional chunks too (by default it extracts only from the initial chunk(s))|
73+
|**`disable`**|`{Boolean}`|Disables the plugin|
74+
|**`ignoreOrder`**|`{Boolean}`|Disables order check (useful for CSS Modules!), `false` by default|
75+
76+
* `[name]` name of the chunk
77+
* `[id]` number of the chunk
78+
* `[contenthash]` hash of the content of the extracted file
7679

77-
The `ExtractTextPlugin` generates an output file per entry, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.
80+
> :warning: `ExtractTextPlugin` generates a file **per entry**, so you must use `[name]`, `[id]` or `[contenthash]` when using multiple entries.
7881
79-
``` javascript
82+
#### `#extract`
83+
84+
```js
8085
ExtractTextPlugin.extract(options: loader | object)
8186
```
8287

83-
Creates an extracting loader from an existing loader. Supports loaders of type `{ loader: string; query: object }`.
88+
Creates an extracting loader from an existing loader. Supports loaders of type `{ loader: [name]-loader -> {String}, options: {} -> {Object} }`.
89+
90+
|Name|Type|Description|
91+
|:--:|:--:|:----------|
92+
|**`options.use`**|`{String}`/`{Array}`/`{Object}`|Loader(s) that should be used for converting the resource to a CSS exporting module _(required)_|
93+
|**`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`)|
94+
|**`options.publicPath`**|`{String}`|Override the `publicPath` setting for this loader|
8495

85-
* `options.loader: string | object | loader[]` _(required)_ the loader(s) that should be used for converting the resource to a css exporting module
86-
* `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`)
87-
* `options.publicPath: string` override the `publicPath` setting for this loader
8896

89-
There is also an `extract` function on the instance. You should use this if you have more than one `ExtractTextPlugin`.
97+
#### Multiple Instances
9098

91-
```javascript
92-
let ExtractTextPlugin = require('extract-text-webpack-plugin');
99+
There is also an `extract` function on the instance. You should use this if you have more than one instance of `ExtractTextPlugin`.
93100

94-
// multiple extract instances
95-
let extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
96-
let extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
101+
```js
102+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
103+
104+
// Create multiple instances
105+
const extractCSS = new ExtractTextPlugin('stylesheets/[name].css');
106+
const extractLESS = new ExtractTextPlugin('stylesheets/[name].less');
97107

98108
module.exports = {
99-
...
100109
module: {
101-
loaders: [
102-
{ test: /\.scss$/i, loader: extractCSS.extract(['css-loader','sass-loader']) },
103-
{ test: /\.less$/i, loader: extractLESS.extract(['css-loader','less-loader']) },
104-
...
110+
rules: [
111+
{
112+
test: /\.css$/,
113+
use: extractCSS.extract([ 'css-loader', 'postcss-loader' ])
114+
},
115+
{
116+
test: /\.less$/i,
117+
use: extractLESS.extract([ 'css-loader', 'less-loader' ])
118+
},
105119
]
106120
},
107121
plugins: [
@@ -111,9 +125,65 @@ module.exports = {
111125
};
112126
```
113127

114-
## Maybe a temp repo
115-
This maybe a temporary repository. Once ```extract-text-webpack-plugin``` merge my pull request, please stick to the origin repo.
128+
### Extracting Sass or LESS
129+
130+
The configuration is the same, switch out `sass-loader` for `less-loader` when necessary.
131+
132+
```js
133+
const ExtractTextPlugin = require('extract-text-webpack-plugin');
134+
135+
module.exports = {
136+
module: {
137+
use: [
138+
{
139+
test: /\.scss$/,
140+
use: ExtractTextPlugin.extract({
141+
fallback: 'style-loader',
142+
//resolve-url-loader may be chained before sass-loader if necessary
143+
use: ['css-loader', 'sass-loader']
144+
})
145+
}
146+
]
147+
},
148+
plugins: [
149+
new ExtractTextPlugin('style.css')
150+
//if you want to pass in options, you can do so:
151+
//new ExtractTextPlugin({
152+
// filename: 'style.css'
153+
//})
154+
]
155+
}
156+
```
157+
158+
<h2 align="center">Maintainer</h2>
159+
160+
<table>
161+
<tbody>
162+
<tr>
163+
<td align="center">
164+
<img width="150" height="150" src="https://github.com/sokra.png?s=150">
165+
<br>
166+
<a href="https://github.com/sokra">Tobias Koppers</a>
167+
</td>
168+
<tr/>
169+
<tbody>
170+
</table>
171+
172+
173+
[npm]: https://img.shields.io/npm/v/extract-text-webpack-plugin.svg
174+
[npm-url]: https://npmjs.com/package/extract-text-webpack-plugin
175+
176+
[node]: https://img.shields.io/node/v/extract-text-webpack-plugin.svg
177+
[node-url]: https://nodejs.org
178+
179+
[deps]: https://david-dm.org/webpack-contrib/extract-text-webpack-plugin.svg
180+
[deps-url]: https://david-dm.org/webpack-contrib/extract-text-webpack-plugin
181+
182+
[tests]: http://img.shields.io/travis/webpack-contrib/extract-text-webpack-plugin.svg
183+
[tests-url]: https://travis-ci.org/webpack-contrib/extract-text-webpack-plugin
116184

117-
## License
185+
[cover]: https://coveralls.io/repos/github/webpack-contrib/extract-text-webpack-plugin/badge.svg
186+
[cover-url]: https://coveralls.io/github/webpack-contrib/extract-text-webpack-plugin
118187

119-
MIT (http://www.opensource.org/licenses/mit-license.php)
188+
[chat]: https://badges.gitter.im/webpack/webpack.svg
189+
[chat-url]: https://gitter.im/webpack/webpack

0 commit comments

Comments
 (0)