Skip to content

Commit b1d2779

Browse files
authored
Merge branch 'master' into next
2 parents 4354b9a + 2082561 commit b1d2779

File tree

11 files changed

+69
-20
lines changed

11 files changed

+69
-20
lines changed

src/components/Support/Support.jsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Backers from './support-backers.json';
33
import Additional from './support-additional.js';
4+
import SmallIcon from '../../assets/icon-square-small-slack.png';
45
import './Support.scss';
56

67
const SUPPORTERS = [ ...Backers ];
@@ -100,11 +101,11 @@ export default class Support extends React.Component {
100101
title={ `$${formatMoney(supporter.totalDonations / 100)} by ${supporter.name || supporter.slug}` }
101102
target="_blank"
102103
href={ supporter.website || `https://opencollective.com/${supporter.slug}` }>
103-
{ supporter.avatar ? <img
104+
{<img
104105
className={ `support__${rank}-avatar` }
105-
src={ supporter.avatar }
106-
alt={ supporter.name || supporter.slug ? `${supporter.name || supporter.slug}'s avatar` : 'avatar' } /> :
107-
<span className={ `support__${rank}-avatar` }>{supporter.name || supporter.slug}</span> }
106+
src={ supporter.avatar || SmallIcon }
107+
alt={ supporter.name || supporter.slug ? `${supporter.name || supporter.slug}'s avatar` : 'avatar' }
108+
onError={ this._handleImgError } />}
108109
{ rank === 'backer' ? <figure className="support__outline" /> : null }
109110
</a>
110111
))
@@ -118,4 +119,14 @@ export default class Support extends React.Component {
118119
</div>
119120
);
120121
}
122+
123+
/**
124+
* Handle images that aren't found
125+
*
126+
* @param {object} e - React synthetic event
127+
*/
128+
_handleImgError(e) {
129+
const imgNode = e.target;
130+
imgNode.src = SmallIcon;
131+
}
121132
}

src/content/api/cli.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ Specifies a different [configuration](/configuration) file to pick up. Use this
109109
webpack --config example.config.js
110110
```
111111

112-
**Suppress output of webpack**
113-
114-
```bash
115-
webpack --silent
116-
```
117-
118112
**Print result of webpack as a JSON**
119113

120114
```bash

src/content/concepts/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ConsoleLogOnBuildWebpackPlugin.prototype.apply = function(compiler) {
3333
};
3434
```
3535

36-
T> As a clever JavaScript developer you may remember the `Function.prototype.apply` method. Because of this method you can pass any function as plugin (`this` will point to the `compiler`). You can use this style to inline custom plugins in your configuration.
36+
T> As a clever JavaScript developer you may remember the [`Function.prototype.apply`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply) method. Because of this method you can pass any function as plugin (`this` will point to the `compiler`). You can use this style to inline custom plugins in your configuration.
3737

3838

3939
## Usage

src/content/configuration/stats.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ stats: {
6262
// Context directory for request shortening
6363
context: "../src/",
6464
// `webpack --colors` equivalent
65-
colors: true,
65+
colors: false,
6666
// Display the distance from the entry point for each module
6767
depth: false,
6868
// Display the entry points with the corresponding bundles

src/content/contribute/writing-a-loader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Loaders should do only a single task. This not only makes the job of maintaining
9898

9999
### Chaining
100100

101-
Take advantage of the fact that loaders can be chained together. Instead of writing a single loader that tackles five tasks, write five simpler loaders that divide this effort. Isolating them not only keeps each individual loader simple, but may allow for them to be used for something you hadn't though of originally.
101+
Take advantage of the fact that loaders can be chained together. Instead of writing a single loader that tackles five tasks, write five simpler loaders that divide this effort. Isolating them not only keeps each individual loader simple, but may allow for them to be used for something you hadn't thought of originally.
102102

103103
Take the case of rendering a template file with data specified via loader options or query parameters. It could be written as a single loader that compiles the template from source, executes it and returns a module that exports a string containing the HTML code. However, in accordance with guidelines, a simple `apply-loader` exists that can be chained with other open source loaders:
104104

src/content/guides/author-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Or, to add as standard module as per [this guide](https://github.com/dherman/def
307307

308308
The key `main` refers to the [standard from `package.json`](https://docs.npmjs.com/files/package.json#main), and `module` to [a](https://github.com/dherman/defense-of-dot-js/blob/master/proposal.md) [proposal](https://github.com/rollup/rollup/wiki/pkg.module) to allow the JavaScript ecosystem upgrade to use ES2015 modules without breaking backwards compatibility.
309309

310-
W> The `module` property should point to a script that utilizes ES2015 module syntax but no other syntax features that aren't yet supported by browsers or node. This enables
310+
W> The `module` property should point to a script that utilizes ES2015 module syntax but no other syntax features that aren't yet supported by browsers or node. This enables webpack to parse the module syntax itself, allowing for lighter bundles via [tree shaking](https://webpack.js.org/guides/tree-shaking/) if users are only consuming certain parts of the library.
311311

312312
Now you can [publish it as an npm package](https://docs.npmjs.com/getting-started/publishing-npm-packages) and find it at [unpkg.com](https://unpkg.com/#/) to distribute it to your users.
313313

src/content/guides/csp.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Content Security Policies
3+
sort: 17
4+
contributors:
5+
- EugeneHlushko
6+
- probablyup
7+
related:
8+
- title: Nonce purpose explained
9+
url: https://stackoverflow.com/questions/42922784/what-s-the-purpose-of-the-html-nonce-attribute-for-script-and-style-elements
10+
- title: On the Insecurity of Whitelists and the Future of Content Security Policy
11+
url: https://research.google.com/pubs/pub45542.html
12+
- title: Locking Down Your Website Scripts with CSP, Hashes, Nonces and Report URI
13+
url: https://www.troyhunt.com/locking-down-your-website-scripts-with-csp-hashes-nonces-and-report-uri/
14+
- title: CSP on MDN
15+
url: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
16+
---
17+
18+
Webpack is capable of adding `nonce` to all scripts that it loads. To activate the feature set a `__webpack_nonce__` variable needs to be included in your entry script. A unique hash based nonce should be generated and provided for each unique page view this is why `__webpack_nonce__` is specified in the entry file and not in the configuration. Please note that `nonce` should always be a base64-encoded string.
19+
20+
21+
## Examples
22+
23+
In the entry file:
24+
25+
``` js
26+
// ...
27+
__webpack_nonce__ = 'c29tZSBjb29sIHN0cmluZyB3aWxsIHBvcCB1cCAxMjM=';
28+
// ...
29+
```
30+
31+
32+
## Enabling CSP
33+
34+
Please note that CSPs are not enable by default. A corresponding header `Content-Security-Policy` or meta tag `<meta http-equiv="Content-Security-Policy" ...>` needs to be sent with the document to instruct the browser to enable the CSP. Here's an example of what a CSP header including a CDN white-listed URL might look like:
35+
36+
``` http
37+
Content-Security-Policy: default-src 'self'; script-src 'self' https://trusted.cdn.com;
38+
```
39+
40+
For more information on CSP and `nonce` attribute, please refer to __Further Reading__ section at the bottom of this page.

src/content/guides/environment-variables.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ contributors:
55
- simon04
66
- grisanu
77
- tbroadley
8+
- legalcodes
89
related:
910
- title: The Fine Art of the webpack 3 Config
1011
url: https://blog.flennik.com/the-fine-art-of-the-webpack-2-config-dc4d19d7f172#d60a
1112
---
1213

13-
To disambiguate in your `webpack.config.js` between [development](/guides/development) and [production builds](/guides/production), you may use environment variables.
14+
To disambiguate in your `webpack.config.js` between [development](/guides/development) and [production builds](/guides/production) you may use environment variables.
1415

15-
The webpack command line [environment option](/api/cli/#environment-options), `--env` allows you to pass in as many environment variables as you like. Environment variables will be made accessible in your `webpack.config.js`. For example, `--env.production` or `--env.NODE_ENV=local` (`NODE_ENV` is conventionally used to define the environment type, see [here](https://dzone.com/articles/what-you-should-know-about-node-env).)
16+
The webpack command line [environment option](/api/cli/#environment-options) `--env` allows you to pass in as many environment variables as you like. Environment variables will be made accessible in your `webpack.config.js`. For example, `--env.production` or `--env.NODE_ENV=local` (`NODE_ENV` is conventionally used to define the environment type, see [here](https://dzone.com/articles/what-you-should-know-about-node-env).)
1617

1718
```bash
1819
webpack --env.NODE_ENV=local --env.production --progress
1920
```
2021

2122
T> Setting up your `env` variable without assignment, `--env.production` sets `--env.production` to `true` by default. There are also other syntaxes that you can use. See the [webpack CLI](/api/cli/#environment-options) documentation for more information.
2223

23-
There is, however a change that you will have to make to your webpack config. Typically, in your webpack config `module.exports` points to the configuration object. To use the `env` variable, you must convert `module.exports` to a function:
24+
There is one change that you will have to make to your webpack config. Typically, `module.exports` points to the configuration object. To use the `env` variable, you must convert `module.exports` to a function:
2425

2526
__webpack.config.js__
2627

src/content/guides/lazy-loading.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ Many frameworks and libraries have their own recommendations on how this should
108108

109109
- React: [Code Splitting and Lazy Loading](https://reacttraining.com/react-router/web/guides/code-splitting)
110110
- Vue: [Lazy Load in Vue using Webpack's code splitting](https://alexjoverm.github.io/2017/07/16/Lazy-load-in-Vue-using-Webpack-s-code-splitting/)
111+
- AngularJS: [AngularJS + Webpack = lazyLoad](https://medium.com/@var_bin/angularjs-webpack-lazyload-bb7977f390dd) by [@var_bincom](https://twitter.com/var_bincom)

src/content/plugins/commons-chunk-plugin.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Similar to the above one, but instead of moving common modules into the parent (
149149
new webpack.optimize.CommonsChunkPlugin({
150150
name: "app",
151151
// or
152-
names: ["app", "subPageA"]
152+
names: ["app", "subPageA"],
153153
// the name or list of names must match the name or names
154154
// of the entry points that create the async chunks
155155

@@ -255,5 +255,5 @@ Since the `vendor` and `manifest` chunk use a different definition for `minChunk
255255
## More Examples
256256
257257
- [Common and Vendor Chunks](https://github.com/webpack/webpack/tree/master/examples/common-chunk-and-vendor-chunk)
258-
- [Multiple Common Chunks](https://github.com/webpack/webpack/tree/master/examples/multiple-commons-chunks)
259-
- [Multiple Entry Points with Commons Chunk](https://github.com/webpack/webpack/tree/master/examples/multiple-entry-points-commons-chunk-css-bundle)
258+
- [Multiple Common Chunks](https://github.com/webpack/webpack/tree/8b888fedfaeaac6bd39168c0952cc19e6c34280a/examples/multiple-commons-chunks)
259+
- [Multiple Entry Points with Commons Chunk](https://github.com/webpack/webpack/tree/8b888fedfaeaac6bd39168c0952cc19e6c34280a/examples/multiple-entry-points-commons-chunk-css-bundle)

src/content/plugins/source-map-dev-tool-plugin.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ title: SourceMapDevToolPlugin
33
contributors:
44
- johnnyreilly
55
- simon04
6+
- neilkennedy
67
related:
78
- title: Building Source Maps
89
url: https://survivejs.com/webpack/building/source-maps/#-sourcemapdevtoolplugin-and-evalsourcemapdevtoolplugin-
@@ -39,6 +40,7 @@ The `fileContext` option is useful when you want to store source maps in an uppe
3940

4041
T> Setting `module` and/or `columns` to `false` will yield less accurate source maps but will also improve compilation performance significantly.
4142

43+
W> Remember that when using the [`UglifyJSPlugin`](/plugins/uglify-js-plugin), you must utilize the `sourceMap` option.
4244

4345
## Examples
4446

0 commit comments

Comments
 (0)