Skip to content

您 -> 你 & 统一为:本指南继续沿用[xxx](/guides/xxx)中的代码示例 #440

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 134 commits into from
Jan 13, 2018
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
f2a258a
update /content/loaders & /content/plugins
dear-lizhihua Sep 3, 2017
a5725bb
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Sep 3, 2017
248be26
update /content/loaders & /content/plugins
dear-lizhihua Sep 19, 2017
36c53b8
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Sep 19, 2017
25a3d6d
Merge branch 'master' into cn
dear-lizhihua Oct 10, 2017
14bff9f
update /content/loaders & /content/plugins
dear-lizhihua Oct 10, 2017
debfddd
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Oct 10, 2017
57fb4d4
update contributors
dear-lizhihua Oct 10, 2017
99bf48d
Merge branch 'master' into translation
dear-lizhihua Oct 10, 2017
7fcd796
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Oct 11, 2017
78e3cee
update /content/loaders & /content/plugins
dear-lizhihua Oct 15, 2017
8a1b2c9
Merge branch 'master' into translation
dear-lizhihua Oct 15, 2017
34575cd
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Oct 15, 2017
3251e8a
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Oct 15, 2017
7396c0d
Merge branch 'master' into cn
dear-lizhihua Oct 15, 2017
c0dc1be
fix LinkDropdown
dear-lizhihua Oct 15, 2017
4809e4a
Merge branch 'translation' into cn
dear-lizhihua Oct 15, 2017
178eeeb
修复 npm 命令错误导致编译不成功的问题
dear-lizhihua Oct 17, 2017
8ec33ad
update /content/loaders & /content/plugins
dear-lizhihua Oct 17, 2017
cc7b5e1
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Oct 17, 2017
93ebe40
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Oct 29, 2017
1ca293a
update /content/loaders & /content/plugins
dear-lizhihua Oct 30, 2017
a132154
Merge branch 'master' into translation
dear-lizhihua Oct 30, 2017
9fbf758
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Oct 30, 2017
a40704a
update /content/loaders & /content/plugins
dear-lizhihua Nov 1, 2017
53d47d1
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Nov 1, 2017
68c4bdd
Merge remote-tracking branch 'upstream/cn' into cn
dear-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
dear-lizhihua Nov 5, 2017
0f539cb
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Nov 5, 2017
c71abf9
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Nov 5, 2017
c9cdb7e
Revert "A new --concatenate-modules flag" (#1692)
skipjack Nov 5, 2017
ebd64c9
update master
dear-lizhihua Nov 6, 2017
796d087
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Nov 6, 2017
4a2422b
Merge branch 'master' into cn
dear-lizhihua Nov 6, 2017
fe130ff
update master
dear-lizhihua Nov 6, 2017
19fc4f6
update /content/loaders & /content/plugins
dear-lizhihua Nov 7, 2017
b9d59a4
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Nov 7, 2017
38fc0d4
Merge branch 'translation' into cn
dear-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
dear-lizhihua Nov 12, 2017
192c38e
update /content/loaders & /content/plugins
dear-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
dear-lizhihua Nov 18, 2017
c5142de
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Nov 18, 2017
5a59bb7
update /content/loaders & /content/plugins
dear-lizhihua Nov 18, 2017
8597638
Merge remote-tracking branch 'upstream/translation' into translation
dear-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
dear-lizhihua Dec 3, 2017
0f36909
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Dec 3, 2017
27991dc
update /src/content/loaders & /src/content/plugins
dear-lizhihua Dec 3, 2017
3ff5dfe
Merge remote-tracking branch 'upstream/translation' into translation
dear-lizhihua Dec 3, 2017
1e898cb
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Dec 3, 2017
46e6781
Merge branch 'translation' into cn
dear-lizhihua Dec 3, 2017
4fe9b6f
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Dec 4, 2017
b5f821d
Merge branch 'master' into cn
dear-lizhihua Dec 4, 2017
8a3c989
docs(contribute): link compiler docs in writing-a-plugin (#1700)
chrmod Dec 5, 2017
968c0d1
docs(guides): fix `source-map` discrepancy in production.md (#1711)
mbsrc Dec 5, 2017
e911daf
docs(guides): rename 'runtime' to 'manifest' in caching.md (#1713)
mbsrc Dec 5, 2017
3d3ab97
docs(guides): update output to webpack 3.9.1 (#1724)
plug-n-play Dec 5, 2017
a4bdaa2
docs(plugins): update the source-map-devtool-plugin (#1707)
EugeneHlushko Dec 5, 2017
5ff8058
docs(contribute): correct an example in the writers-guide (#1727)
lhoff Dec 5, 2017
4d82b1c
docs(config): improve formatting and add note about library entry poi…
skipjack Dec 6, 2017
f0b140a
docs(guides): mention complex entry point configuration in author-lib…
skipjack Dec 6, 2017
099d928
docs(config): improve formatting and clarify the string usage in exte…
skipjack Dec 6, 2017
d6dee86
docs(config): fix minor proselint error in externals
skipjack Dec 6, 2017
c0db521
docs(api): clarify the `pitch` method and how it can be used in loade…
skipjack Dec 6, 2017
9e77d93
docs(contribute): fix `import` statement in writing-a-loader.md (#1732)
sanchitnevgi Dec 8, 2017
2c47976
docs(config): update devtool production recommendations
neonick Dec 6, 2017
9b8653f
docs(api): remove obsolete cli flag (#1733)
ooflorent Dec 9, 2017
8b5fd79
docs(concepts): add warning about incompatible `import` statements
skipjack Dec 9, 2017
4902981
docs(config): fix typescript setup in configuration-languages (#1734)
youta1119 Dec 11, 2017
093722e
docs: use full `npm install` over `npm i` (#1740)
Chocobo1 Dec 14, 2017
1c17320
docs(guides): fix diff display for webpack.config.js entry object
JGJP Dec 14, 2017
4405fee
docs: fix typos
tbroadley Dec 16, 2017
df39d5f
docs: add tbroadley to contributor lists
tbroadley Dec 16, 2017
7018c23
docs(contribute): correct schema example in `writing-a-loader.md` (#1…
warmrobot Dec 18, 2017
f0ffd1f
docs(guides): add pwa guide (#1737)
johnnyreilly Dec 18, 2017
41615e4
docs(guides): highlight css splitting in production
skipjack Dec 18, 2017
1b5cf43
docs(plugins): use `.includes` over `.indexOf`
baldurh Dec 18, 2017
41a5096
docs(config): omit invalid `detailed` option in stats.md (#1757)
Dec 20, 2017
7078bd7
fix(mobile): correctly sort pages in mobile sidebar (#1759)
pierreneter Dec 20, 2017
a5566a1
chore(vote): port voting app, update deps, and simplify config (#1717)
skipjack Dec 23, 2017
679ed0a
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Dec 23, 2017
e8b2e06
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Dec 23, 2017
0d6cb2e
docs(readme): reformat at 80 characters and include browserstack link
skipjack Dec 22, 2017
aceaf6e
refactor(notification): simplify notification message and bump the ve…
skipjack Dec 26, 2017
fd4548f
fix(splash): fix visualization artifacts (#1762)
pierreneter Dec 27, 2017
1ec37d9
chore: pick up vote fix and update yarn lock file
skipjack Dec 27, 2017
6e06115
chore(vote): pick up another vote patch
skipjack Dec 28, 2017
f375e60
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Dec 28, 2017
eb02652
Update index.md (#423)
DanielXH Dec 28, 2017
cd39b03
Update .travis.yml
dear-lizhihua Dec 29, 2017
9a14935
docs: fix formatting and grammar (#1765)
yangshun Jan 7, 2018
232bf00
docs(concepts): change loader order from chonological to reverse (#1767)
Jan 7, 2018
e5a36ae
Merge remote-tracking branch 'upstream/master'
dear-lizhihua Jan 13, 2018
17e1fc8
Merge branch 'master' into cn
dear-lizhihua Jan 13, 2018
c46b22a
update UPDATE.md
dear-lizhihua Jan 13, 2018
7d79c30
https://github.com/webpack-china/webpack.js.org/pull/422
dear-lizhihua Jan 13, 2018
48d38a0
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Jan 13, 2018
8685372
https://github.com/webpack-china/webpack.js.org/issues/40
dear-lizhihua Jan 13, 2018
7e71b5d
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Jan 13, 2018
8fb61a3
您 -> 你 & 统一为:本指南继续沿用[xxx](/guides/xxx)中的代码示例
dear-lizhihua Jan 13, 2018
be132a2
Merge remote-tracking branch 'upstream/cn' into cn
dear-lizhihua Jan 13, 2018
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
112 changes: 61 additions & 51 deletions src/content/api/loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,56 @@ A single result can be returned in **sync mode**. For multiple results the `this

## Examples

### Sync Loader
The following sections provide some basic examples of the different types of loaders. Note that the `map` and `meta` parameters are optional, see [`this.callback`](/api/loaders#this-callback) below.

**sync-loader.js**
### Synchronous Loaders

```javascript
module.exports = function(content) {
Either `return` or `this.callback` can be used to return the transformed `content` synchronously:

__sync-loader.js__

``` js
module.exports = function(content, map, meta) {
return someSyncOperation(content);
};
```

**sync-loader-with-multiple-results.js**
The `this.callback` method is more flexible as it allows multiple arguments to be passed as opposed to just the `content`.

```javascript
module.exports = function(content) {
this.callback(null, someSyncOperation(content), sourceMaps, ast);
__sync-loader-with-multiple-results.js__

``` js
module.exports = function(content, map, meta) {
this.callback(null, someSyncOperation(content), sourceMaps, meta);
return; // always return undefined when calling callback()
};
```

### Asynchronous Loaders

### Async Loader
For asynchronous loaders, [`this.async`](/api/loaders#this-async) is used to retrieve the `callback` function:

**async-loader.js**
__async-loader.js__

```javascript
module.exports = function(content) {
var callback = this.async();
someAsyncOperation(content, function(err, result) {
if(err) return callback(err);
callback(null, result);
});
``` js
module.exports = function(content, map, meta) {
var callback = this.async();
someAsyncOperation(content, function(err, result) {
if (err) return callback(err);
callback(null, result, map, meta);
});
};
```

**async-loader-with-multiple-results.js**
__async-loader-with-multiple-results.js__

```javascript
module.exports = function(content) {
var callback = this.async();
someAsyncOperation(content, function(err, result, sourceMaps, ast) {
if(err) return callback(err);
callback(null, result, sourceMaps, ast);
});
``` js
module.exports = function(content, map, meta) {
var callback = this.async();
someAsyncOperation(content, function(err, result, sourceMaps, meta) {
if (err) return callback(err);
callback(null, result, sourceMaps, meta);
});
};
```

Expand All @@ -68,9 +75,9 @@ T> Loaders were originally designed to work in synchronous loader pipelines, lik

By default, the resource file is converted to a UTF-8 string and passed to the loader. By setting the `raw` flag, the loader will receive the raw `Buffer`. Every loader is allowed to deliver its result as `String` or as `Buffer`. The compiler converts them between loaders.

**raw-loader.js**
__raw-loader.js__

```javascript
``` js
module.exports = function(content) {
assert(content instanceof Buffer);
return someSyncOperation(content);
Expand All @@ -83,14 +90,15 @@ module.exports.raw = true;

### Pitching Loader

Loaders are **always** called from right to left. But, in some cases, loaders do not care about the results of the previous loader or the resource. They only care for **metadata**. The `pitch` method on the loaders is called from **left to right** before the loaders are called (from right to left).
Loaders are **always** called from right to left. But, in some cases, loaders do not care about the results of the previous loader or the resource. They only care about **metadata**. The `pitch` method on the loaders is called from **left to right** before the loaders are called (from right to left).

If a loader delivers a result in the `pitch` method the process turns around and skips the remaining loaders, continuing with the calls to the more left loaders. `data` can be passed between pitch and normal call.

```javascript
``` js
module.exports = function(content) {
return someSyncOperation(content, this.data.value);
};

module.exports.pitch = function(remainingRequest, precedingRequest, data) {
if(someCondition()) {
// fast exit
Expand All @@ -101,14 +109,14 @@ module.exports.pitch = function(remainingRequest, precedingRequest, data) {
```


## The loader context
## The Loader Context

The loader context represents the properties that are available inside of a loader assigned to the `this` property.

Given the following example this require call is used:
In `/abc/file.js`:

```javascript
``` js
require("./loader1?xyz!loader2!./resource?rrr");
```

Expand Down Expand Up @@ -137,26 +145,28 @@ In the example: `"/abc/loader1.js?xyz!/abc/node_modules/loader2/index.js!/abc/re
1. If the loader was configured with an [`options`](/configuration/module/#useentry) object, this will point to that object.
2. If the loader has no `options`, but was invoked with a query string, this will be a string starting with `?`.

W> This property is deprecated as `options` is replacing `query`. Use the [`getOptions` method from the `loader-utils`](https://github.com/webpack/loader-utils#getoptions) to extract the given loader options.
W> This property is deprecated as `options` is replacing `query`. Use the [`getOptions` method](https://github.com/webpack/loader-utils#getoptions) from `loader-utils` to extract the given loader options.


### `this.callback`

A function that can be called synchronously or asynchronously in order to return multiple results. The expected arguments are:

```typescript
``` js
this.callback(
err: Error | null,
content: string | Buffer,
sourceMap?: SourceMap,
abstractSyntaxTree?: AST
err: Error | null,
content: string | Buffer,
sourceMap?: SourceMap,
meta?: any
);
```

1. The first argument must be an `Error` or `null`
2. The second argument a `string` or a [`Buffer`](https://nodejs.org/api/buffer.html).
3. Optional: The third argument must be a source map that is parsable by [this module](https://github.com/mozilla/source-map).
4. Optional: `AST` can be an Abstract Syntax Tree of the given language, like [`ESTree`](https://github.com/estree/estree). This value is ignored by webpack itself, but useful to speed up the build time if you want to share common ASTs between loaders.
4. Optional: The fourth option, ignored by webpack, can be anything (e.g. some meta data).

T> It can be useful to pass an abstract syntax tree (AST), like [`ESTree`](https://github.com/estree/estree), as the fourth argument (`meta`) to speed up the build time if you want to share common ASTs between loaders.

In case this function is called, you should return undefined to avoid ambigious loader results.

Expand All @@ -175,7 +185,7 @@ A data object shared between the pitch and the normal phase.

A function that sets the cacheable flag:

```typescript
``` typescript
cacheable(flag = true: boolean)
```

Expand All @@ -188,13 +198,13 @@ A cacheable loader must have a deterministic result, when inputs and dependencie

An array of all the loaders. It is writeable in the pitch phase.

```typescript
``` js
loaders = [{request: string, path: string, query: string, module: function}]
```

In the example:

```javascript
``` js
[
{
request: "/abc/loader1.js?xyz",
Expand Down Expand Up @@ -261,7 +271,7 @@ Should a source map be generated. Since generating source maps can be an expensi

### `this.emitWarning`

```typescript
``` typescript
emitWarning(warning: Error)
```

Expand All @@ -270,7 +280,7 @@ Emit a warning.

### `this.emitError`

```typescript
``` typescript
emitError(error: Error)
```

Expand All @@ -279,7 +289,7 @@ Emit an error.

### `this.loadModule`

```typescript
``` typescript
loadModule(request: string, callback: function(err, source, sourceMap, module))
```

Expand All @@ -288,7 +298,7 @@ Resolves the given request to a module, applies all configured loaders and calls

### `this.resolve`

```typescript
``` typescript
resolve(context: string, request: string, callback: function(err, result: string))
```

Expand All @@ -297,7 +307,7 @@ Resolve a request like a require expression.

### `this.addDependency`

```typescript
``` typescript
addDependency(file: string)
dependency(file: string) // shortcut
```
Expand All @@ -307,7 +317,7 @@ Adds a file as dependency of the loader result in order to make them watchable.

### `this.addContextDependency`

```typescript
``` typescript
addContextDependency(directory: string)
```

Expand All @@ -316,7 +326,7 @@ Add a directory as dependency of the loader result.

### `this.clearDependencies`

```typescript
``` typescript
clearDependencies()
```

Expand All @@ -325,7 +335,7 @@ Remove all dependencies of the loader result. Even initial dependencies and thes

### `this.emitFile`

```typescript
``` typescript
emitFile(name: string, content: Buffer|string, sourceMap: {...})
```

Expand All @@ -344,7 +354,7 @@ W> The usage of these properties is highly discouraged since we are planing to r

### `this.exec`

```typescript
``` typescript
exec(code: string, filename: string)
```

Expand All @@ -353,7 +363,7 @@ Execute some code fragment like a module. See [this comment](https://github.com/

### `this.resolveSync`

```typescript
``` typescript
resolveSync(context: string, request: string) -> string
```

Expand Down
2 changes: 1 addition & 1 deletion src/content/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contributors:
- TheDutchCoder
---

At its core, *webpack* is a _module bundler_ for modern JavaScript applications. When webpack processes your application, it recursively builds a _dependency graph_ that includes every module your application needs, then packages all of those modules into one or more _bundles_.
At its core, *webpack* is a _static module bundler_ for modern JavaScript applications. When webpack processes your application, it recursively builds a _dependency graph_ that includes every module your application needs, then packages all of those modules into one or more _bundles_.

It is [incredibly configurable](/configuration), but to get started you only need to understand four **Core Concepts**:

Expand Down
2 changes: 1 addition & 1 deletion src/content/concepts/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ contributors:
- rouzbeh84
---

Configuring the `output` configuration options tell webpack how to write the compiled files to disk. Note that, while there can be multiple `entry` points, only one `output` configuration is specified.
Configuring the `output` configuration options tells webpack how to write the compiled files to disk. Note that, while there can be multiple `entry` points, only one `output` configuration is specified.


## Usage
Expand Down
6 changes: 6 additions & 0 deletions src/content/configuration/dev-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,12 @@ Usage via the CLI
webpack-dev-server --open
```

If no browser is provided (as shown above), your default browser will be used. To specify a different browser, just pass its name:

```bash
webpack-dev-server --open 'Google Chrome'
```


## `devServer.openPage`

Expand Down
2 changes: 1 addition & 1 deletion src/content/contribute/writing-a-loader.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ __src/loader.js__
``` js
import { getOptions } from 'loader-utils';

export default source => {
export default function loader(source) {
const options = getOptions(this);

source = source.replace(/\[name\]/g, options.name);
Expand Down
4 changes: 1 addition & 3 deletions src/content/guides/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ __webpack.prod.js__
sourceMap: true
}),
+ new webpack.DefinePlugin({
+ 'process.env': {
+ 'NODE_ENV': JSON.stringify('production')
+ }
+ 'process.env.NODE_ENV': JSON.stringify('production')
+ })
]
})
Expand Down
3 changes: 2 additions & 1 deletion src/content/plugins/html-webpack-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ config as follows:

```javascript
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require('path');

var webpackConfig = {
entry: 'index.js',
output: {
path: 'dist',
path: path.resolve(__dirname, './dist'),
filename: 'index_bundle.js'
},
plugins: [new HtmlWebpackPlugin()]
Expand Down
15 changes: 14 additions & 1 deletion src/content/plugins/source-map-dev-tool-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ The `lineToLine` object allows for the same `test`, `include`, and `exclude` opt
T> Setting `module` and/or `columns` to `false` will yield less accurate source maps but will also improve compilation performance significantly.


## Usage: Exclude Vendor Maps
## Examples

### Exclude Vendor Maps

The following code would exclude source maps for any modules in the `vendor.js` bundle:

Expand All @@ -45,3 +47,14 @@ new webpack.SourceMapDevToolPlugin({
exclude: ['vendor.js']
})
```

### Host Source Maps Externally

Set a URL for source maps. Useful for hosting them on a host that requires authorization.

```javascript
new webpack.SourceMapDevToolPlugin({
append: "\n//# sourceMappingURL=http://example.com/sourcemap/[url]",
filename: '[name].map',
}),
```
2 changes: 1 addition & 1 deletion src/styles/markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
font-size: 90%;
margin: 0 2px;
padding: 2px 6px;
white-space: nowrap;
white-space: normal;
background-color: transparentize(getColor(fiord), 0.94);
border-radius: 3px;
text-shadow: 0 1px 0 transparentize(getColor(white), 0.4);
Expand Down