Skip to content

update master & update loaders & update plugins #418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 86 commits into from
Dec 23, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f2a258a
update /content/loaders & /content/plugins
hello-lizhihua Sep 3, 2017
a5725bb
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Sep 3, 2017
248be26
update /content/loaders & /content/plugins
hello-lizhihua Sep 19, 2017
36c53b8
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Sep 19, 2017
25a3d6d
Merge branch 'master' into cn
hello-lizhihua Oct 10, 2017
14bff9f
update /content/loaders & /content/plugins
hello-lizhihua Oct 10, 2017
debfddd
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Oct 10, 2017
57fb4d4
update contributors
hello-lizhihua Oct 10, 2017
99bf48d
Merge branch 'master' into translation
hello-lizhihua Oct 10, 2017
7fcd796
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Oct 11, 2017
78e3cee
update /content/loaders & /content/plugins
hello-lizhihua Oct 15, 2017
8a1b2c9
Merge branch 'master' into translation
hello-lizhihua Oct 15, 2017
34575cd
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Oct 15, 2017
3251e8a
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Oct 15, 2017
7396c0d
Merge branch 'master' into cn
hello-lizhihua Oct 15, 2017
c0dc1be
fix LinkDropdown
hello-lizhihua Oct 15, 2017
4809e4a
Merge branch 'translation' into cn
hello-lizhihua Oct 15, 2017
178eeeb
修复 npm 命令错误导致编译不成功的问题
hello-lizhihua Oct 17, 2017
8ec33ad
update /content/loaders & /content/plugins
hello-lizhihua Oct 17, 2017
cc7b5e1
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Oct 17, 2017
93ebe40
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Oct 29, 2017
1ca293a
update /content/loaders & /content/plugins
hello-lizhihua Oct 30, 2017
a132154
Merge branch 'master' into translation
hello-lizhihua Oct 30, 2017
9fbf758
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Oct 30, 2017
a40704a
update /content/loaders & /content/plugins
hello-lizhihua Nov 1, 2017
53d47d1
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Nov 1, 2017
68c4bdd
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Nov 1, 2017
d622470
docs(plugins): fix typo in module-concatenation-plugin.md (#1683)
mattdsteele Nov 1, 2017
52eb2a4
docs(concepts): simplify the introduction (#1673)
TheDutchCoder Nov 1, 2017
6e8d65d
docs(plugins): add “scope hoisting” intro in module-concatenation-plu…
iamakulov Nov 3, 2017
66443e6
docs(api): fix some method signatures in loaders.md (#1685)
aparajita Nov 3, 2017
b13613e
update /content/loaders & /content/plugins
Nov 4, 2017
0e407de
Merge remote-tracking branch 'upstream/translation' into translation
Nov 4, 2017
d6295cc
Merge remote-tracking branch 'upstream/master'
Nov 4, 2017
955b221
docs(guides): consistent quoute use in typescript.md (#1687)
ulrikstrid Nov 5, 2017
ac739ee
docs(api/guides): document new --concatenate-modules flag (#1686)
iamakulov Nov 5, 2017
6d30cac
docs(guides): fix issues with examples in shimming.md (#1680)
svyandun Nov 5, 2017
ccac872
docs(guides): add middleware tip to the hmr guide
skipjack Nov 5, 2017
5dcd8ac
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Nov 5, 2017
0f539cb
Merge remote-tracking branch 'upstream/master'
hello-lizhihua Nov 5, 2017
c71abf9
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Nov 5, 2017
c9cdb7e
Revert "A new --concatenate-modules flag" (#1692)
skipjack Nov 5, 2017
ebd64c9
update master
hello-lizhihua Nov 6, 2017
796d087
Merge remote-tracking branch 'upstream/master'
hello-lizhihua Nov 6, 2017
4a2422b
Merge branch 'master' into cn
hello-lizhihua Nov 6, 2017
fe130ff
update master
hello-lizhihua Nov 6, 2017
19fc4f6
update /content/loaders & /content/plugins
hello-lizhihua Nov 7, 2017
b9d59a4
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Nov 7, 2017
38fc0d4
Merge branch 'translation' into cn
hello-lizhihua Nov 7, 2017
34dd7b4
docs(concepts): fix grammar in output.md (#1694)
reergymerej Nov 10, 2017
29899d8
docs(contribute): update writing-a-loader (#1691)
ThaNarie Nov 10, 2017
5a7cbe7
docs(plugins): add external example in SourceMapDevToolPlugin (#1676)
hkrutzer Nov 10, 2017
4760409
docs(config): update dev-server open option (#1693)
applemate Nov 11, 2017
63574ba
fix bugs
hello-lizhihua Nov 12, 2017
192c38e
update /content/loaders & /content/plugins
hello-lizhihua Nov 12, 2017
1511650
docs(api): improve formatting and grammar in loaders.md
skipjack Nov 11, 2017
ab6f188
docs(api): clarify fourth parameter of `this.callback` in loaders.md
skipjack Nov 11, 2017
e6c94a4
docs(api): populate missing link in loaders.md
skipjack Nov 12, 2017
4b80c8b
docs(plugins): correct example in html-webpack-plugin (#1698)
Jocs Nov 13, 2017
b24ea5e
docs(guides): update an example in production.md (#1696)
ogonkov Nov 13, 2017
0fb8a35
fix(markdown): fix overflowing inline code (#1701)
kamleshchandnani Nov 15, 2017
251f704
docs(concepts): update concepts wording (#1702)
TheLarkInn Nov 15, 2017
4f2f269
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Nov 18, 2017
c5142de
Merge remote-tracking branch 'upstream/master'
hello-lizhihua Nov 18, 2017
5a59bb7
update /content/loaders & /content/plugins
hello-lizhihua Nov 18, 2017
8597638
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Nov 18, 2017
4d2e2b8
docs(config): fix dead link to webpack-dev-server example (#1704)
loilo Nov 19, 2017
549d14c
docs(concepts): use fragment links in usage instructions (#1705)
CentroDL Nov 19, 2017
9f473f5
docs(guides): add windows usage tip in getting-started (#1671)
Vanguard90 Nov 23, 2017
b8e8365
doc(guides): fix grammatical error in build-performance (#1709)
davesidious Nov 23, 2017
067cb0d
docs(guides): correct two small typos
mbsrc Nov 21, 2017
e57a11b
docs(api): remove inadvertent double verb (#1714)
MajorBreakfast Nov 23, 2017
2efe399
docs(contribute): fix grammar in writing-a-plugin (#1715)
MajorBreakfast Nov 23, 2017
05714b5
docs(config): add semicolon for consistency (#1716)
connorholyday Nov 26, 2017
93e4b4d
docs(contributing): add note about debian OS (#1721)
sukrosono Dec 2, 2017
4eefcee
docs(guides): add output example to shimming doc (#1720)
agudulin Dec 2, 2017
afe298d
docs(plugins): use `.includes` over `.indexOf` (#1719)
mattvagni Dec 2, 2017
955ff3f
docs(guides): use `npx` in getting-started (#1708)
MajorBreakfast Dec 2, 2017
efcce14
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Dec 3, 2017
0f36909
Merge remote-tracking branch 'upstream/master'
hello-lizhihua Dec 3, 2017
27991dc
update /src/content/loaders & /src/content/plugins
hello-lizhihua Dec 3, 2017
3ff5dfe
Merge remote-tracking branch 'upstream/translation' into translation
hello-lizhihua Dec 3, 2017
1e898cb
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Dec 3, 2017
46e6781
Merge branch 'translation' into cn
hello-lizhihua Dec 3, 2017
4fe9b6f
Merge remote-tracking branch 'upstream/cn' into cn
hello-lizhihua Dec 4, 2017
b5f821d
Merge branch 'master' into cn
hello-lizhihua Dec 4, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/loaders/babel-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __Notes:__ Issues with the output should be reported on the babel [issue tracker
> webpack 3.x | babel-loader 8.x | babel 7.x

```bash
npm install [email protected] @babel/core@next @babel/preset-env@next webpack
npm install [email protected] @babel/core @babel/preset-env webpack
```

> webpack 3.x babel-loader 7.x | babel 6.x
Expand Down
66 changes: 55 additions & 11 deletions src/content/loaders/cache-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source: https://raw.githubusercontent.com/webpack-contrib/cache-loader/master/RE
edit: https://github.com/webpack-contrib/cache-loader/edit/master/README.md
repo: https://github.com/webpack-contrib/cache-loader
---
Caches the result of following loaders on disk
Caches the result of following loaders on disk (default) or in the database

## Install

Expand Down Expand Up @@ -40,8 +40,11 @@ module.exports = {

|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`cacheDirectory`**|`{String}`|`path.resolve('.cache-loader')`|Provide a cache directory where cache items should be stored|
|**`cacheIdentifier`**|`{String}`|`cache-loader:{version} {process.env.NODE_ENV}`|Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders.|
|**`cacheKey`**|`{Function(options, request) -> {String}}`|`undefined`|Allows you to override default cache key generator|
|**`cacheDirectory`**|`{String}`|`path.resolve('.cache-loader')`|Provide a cache directory where cache items should be stored (used for default read/write implementation)|
|**`cacheIdentifier`**|`{String}`|`cache-loader:{version} {process.env.NODE_ENV}`|Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders (used for default read/write implementation)|
|**`write`**|`{Function(cacheKey, data, callback) -> {void}}`|`undefined`|Allows you to override default write cache data to file (e.g. Redis, memcached)|
|**`read`**|`{Function(cacheKey, callback) -> {void}}`|`undefined`|Allows you to override default read cache data from file|

## Examples

Expand All @@ -67,6 +70,52 @@ module.exports = {

**webpack.config.js**
```js
// Or different database client - memcached, mongodb, ...
const redis = require('redis');
const crypto = require('crypto');

// ...
// connect to client
// ...

const BUILD_CACHE_TIMEOUT = 24 * 3600; // 1 day

function digest(str) {
return crypto.createHash('md5').update(str).digest('hex');
}

// Generate own cache key
function cacheKey(options, request) {
return `build:cache:${digest(request)}`;
}


// Read data from database and parse them
function read(key, callback) {
client.get(key, (err, result) => {
if (err) {
return callback(err);
}

if (!result) {
return callback(new Error(`Key ${key} not found`));
}

try {
let data = JSON.parse(result);
callback(null, data);
} catch (e) {
callback(e);
}
});
}


// Write data to database under cacheKey
function write(key, data, callback) {
client.set(key, JSON.stringify(data), 'EX', BUILD_CACHE_TIMEOUT, callback);
}

module.exports = {
module: {
rules: [
Expand All @@ -76,7 +125,9 @@ module.exports = {
{
loader: 'cache-loader',
options: {
cacheDirectory: path.resolve('.cache')
cacheKey,
read,
write,
}
},
'babel-loader'
Expand Down Expand Up @@ -114,13 +165,6 @@ module.exports = {
Joshua Wiens
</a>
</td>
<td align="center">
<a href="https://github.com/sapegin">
<img width="150" height="150" src="https://github.com/sapegin.png?v=3&s=150">
</br>
Artem Sapegin
</a>
</td>
<td align="center">
<a href="https://github.com/michael-ciniawsky">
<img width="150" height="150" src="https://github.com/michael-ciniawsky.png?v=3&s=150">
Expand Down
10 changes: 5 additions & 5 deletions src/content/loaders/expose-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require("expose-loader?libraryName!./file.js");

For example, let's say you want to expose jQuery as a global called `$`:

```
```js
require("expose-loader?$!jquery");
```

Expand All @@ -34,15 +34,15 @@ Thus, `window.$` is then available in the browser console.
Alternately, you can set this in your config file:

webpack v1 usage
```
```js
module: {
loaders: [
{ test: require.resolve("jquery"), loader: "expose-loader?$" }
]
}
```
webpack v2 usage
```
```js
module: {
rules: [{
test: require.resolve('jquery'),
Expand All @@ -58,15 +58,15 @@ Let's say you also want to expose it as `window.jQuery` in addition to `window.$
For multiple expose you can use `!` in loader string:

webpack v1 usage
```
```js
module: {
loaders: [
{ test: require.resolve("jquery"), loader: "expose-loader?$!expose-loader?jQuery" },
]
}
```
webpack v2 usage
```
```js
module: {
rules: [{
test: require.resolve('jquery'),
Expand Down
89 changes: 89 additions & 0 deletions src/content/plugins/closure-webpack-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: ClosureWebpackPlugin
source: https://raw.githubusercontent.com/webpack-contrib/closure-webpack-plugin/master/README.md
edit: https://github.com/webpack-contrib/closure-webpack-plugin/edit/master/README.md
repo: https://github.com/webpack-contrib/closure-webpack-plugin
---


[![npm version](https://badge.fury.io/js/closure-webpack-plugin.svg)](https://badge.fury.io/js/closure-webpack-plugin)

[Closure-Compiler](https://developers.google.com/closure/compiler/) is a full optimizing compiler and transpiler.
It offers unmatched optimizations, provides type checking and can easily target transpilation to different versions of ECMASCRIPT.

**Note:** This plugin is a very early beta and currently uses a custom build of closure-compiler while neccessary changes are integrated back into the main compiler repository.
Only the java version of closure-compiler is currently supported.

## Usage example

```js
const ClosureCompilerPlugin = require('closure-webpack-plugin');

new ClosureCompilerPlugin({mode: 'STANDARD'}, {
// compiler flags here
//
// for debuging help, try these:
//
// formatting: 'PRETTY_PRINT'
// debug: true
})
```

## Options

* **mode** - `STANDARD` (default) or `AGGRESSIVE_BUNDLE`. Controls how the plugin utilizes the compiler.
In `STANDARD` mode, closure-compiler is used as a direct replacement for other minifiers as well as most Babel transformations.
In `AGGRESSIVE_BUNDLE` mode, the compiler performs additional optimizations of modules to produce a much smaller file, but
is not compatible with all input modules.

## Compiler Flags

The plugin controls certain compiler flags. The following flags should not be used in any mode:

* **module_resolution** - A custom resolution mode for webpack is utilized instead of the standard NODE or BROWSER options.
* **output_wrapper** - The output wrapper is automatically added by either webpack or the plugin
* **dependency_mode** - Controlled by the plugin mode.

## Aggressive Bundle Mode

In this mode, the compiler rewrites CommonJS modules and hoists require calls. Some modules are not compatible with this type of rewritting. In particular, hoisting will cause the following code to execute out of order:

```js
const foo = require('foo');
addPolyfillToFoo(foo);
const bar = require('bar');
```

Aggressive Bundle Mode utilizes a custom runtime in which modules within a chunk file are all included in the same scope.
This avoids [the cost of small modules](https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/).

In Aggressive Bundle Mode, a file can only appear in a single output chunk. Use the [Commons Chunk Plugin](https://webpack.js.org/plugins/commons-chunk-plugin/) to split duplicated files into a single output chunk.

## Tips for Use
* Don't use babel - closure-compiler is also a transpiler.
If you need [features not yet supported](https://github.com/google/closure-compiler/wiki/ECMAScript6) by closure-compiler, have babel
only target those features.


## Maintainers

<table>
<tbody>
<tr>
<td align="center">
<a href="https://github.com/ChadKillingsworth">
<img width="150" alt="" height="150" src="https://avatars.githubusercontent.com/u/1247639?v=3">
</br>
Chad Killingsworth
</a>
</td>
<td align="center">
<a href="https://github.com/d3viant0ne">
<img width="150" alt="" height="150" src="https://avatars.githubusercontent.com/u/8420490?v=3">
</br>
Joshua Wiens
</a>
</td>
</tr>
<tbody>
</table>
24 changes: 12 additions & 12 deletions src/content/plugins/uglifyjs-webpack-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ npm i -D uglifyjs-webpack-plugin

**webpack.config.js**
```js
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

module.exports = {
plugins: [
new UglifyJSPlugin()
new UglifyJsPlugin()
]
}
```
Expand All @@ -46,7 +46,7 @@ module.exports = {
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
test: /\.js($|\?)/i
})
]
Expand All @@ -57,7 +57,7 @@ module.exports = {
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
include: /\/includes/
})
]
Expand All @@ -68,7 +68,7 @@ module.exports = {
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
exclude: /\/excludes/
})
]
Expand All @@ -81,7 +81,7 @@ module.exports = {
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
cache: true
})
]
Expand All @@ -95,7 +95,7 @@ Default path to cache directory: `node_modules/.cache/uglifyjs-webpack-plugin`.
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
cache: 'path/to/cache'
})
]
Expand All @@ -110,7 +110,7 @@ Path to cache directory.
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
parallel: true
})
]
Expand All @@ -124,7 +124,7 @@ Default number of concurrent runs: `os.cpus().length - 1`.
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
parallel: 4
})
]
Expand All @@ -139,7 +139,7 @@ Number of concurrent runs.
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
sourceMap: true
})
]
Expand All @@ -162,7 +162,7 @@ Number of concurrent runs.
**webpack.config.js**
```js
[
new UglifyJSPlugin({
new UglifyJsPlugin({
uglifyOptions: {
ie8: false,
ecma: 8,
Expand Down Expand Up @@ -200,7 +200,7 @@ All comments that match the given expression (resp. are evaluated to `true` by t
|Name|Type|Default|Description|
|:--:|:--:|:-----:|:----------|
|**`condition`**|`{Regex\|Function}`|``|Regular Expression or function (see previous point)|
|**`filename`**|`{String\|Function}`|`compilation.assets[file]`|The file where the extracted comments will be stored. Can be either a `{String}` or a `{Function<(string) -> {String}>}`, which will be given the original filename. Default is to append the suffix `.LICENSE` to the original filename|
|**`filename`**|`{String\|Function}`|`${file}.LICENSE`|The file where the extracted comments will be stored. Can be either a `{String}` or a `{Function<(string) -> {String}>}`, which will be given the original filename. Default is to append the suffix `.LICENSE` to the original filename|
|**`banner`**|`{Boolean\|String\|Function}`|`/*! For license information please see ${filename}.js.LICENSE */`|The banner text that points to the extracted file and will be added on top of the original file. Can be `false` (no banner), a `{String}`, or a `{Function<(string) -> {String}` that will be called with the filename where extracted comments have been stored. Will be wrapped into comment|

### `warningsFilter`
Expand Down