Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
dear-lizhihua committed Mar 6, 2017
2 parents 4f33f8a + 92ec0c5 commit 26d8f93
Show file tree
Hide file tree
Showing 14 changed files with 754 additions and 934 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ node_js:
script:
- bash ./scripts/deploy.sh
sudo: required
cache: yarn
install:
- npm i yarn -g
- yarn
Expand Down
4 changes: 2 additions & 2 deletions components/notification-bar/notification-bar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class NotificationBar extends React.Component {
<div className={ `notification-bar ${dismissedMod}` }>
<Container className="notification-bar__inner">
<p>
赞助 webpack,同时获取官方衣服!访问 <a href="https://webpack.threadless.com">webpack 官方商店!</a>&nbsp; 所有收益都转到 webpack 的 <a href="https://opencollective.com/webpack">Open Collective 页面!</a>
赞助 webpack,同时获取官方衣服!访问 <a href="https://webpack.threadless.com">webpack 官方商店!</a>&nbsp; 查看所有收益请转到 webpack 的 <a href="https://opencollective.com/webpack">Open Collective 页面!</a>
</p>
<p>
webpack 2 已经发布!阅读<a href="https://medium.com/webpack/webpack-2-and-beyond-40520af9067f#.ojp0x5ls1">公告</a>&nbsp;并且现在就<a href="/guides/installation">安装它</a>&nbsp;!
Expand Down Expand Up @@ -46,4 +46,4 @@ export default class NotificationBar extends React.Component {

} else return false;
}
}
}
2 changes: 1 addition & 1 deletion components/organization/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
"repo": "webpack/i18n-webpack-plugin",
"npm": "i18n-webpack-plugin",
"description": "Embed localization into your bundle.",
"maintainer": "EcutDavid"
"maintainer": ""
},
{
"repo": "webpack/json5-loader",
Expand Down
2 changes: 1 addition & 1 deletion content/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ webpack.js index=./src/index.js index2=./src/index2.js --output-path='./dist' --

| 参数 | 说明 | 使用方法 |
|--------------------|---------------------------|-----------------------------|
| --module-bind | 为 loader 绑定一个扩展 | --module-bind /\.js$/=babel |
| --module-bind | 为 loader 绑定一个扩展 | --module-bind /\.js$/=babel-loader |
| --module-bind-post | 为 post loader 绑定一个扩展 | |
| --module-bind-pre | 为 pre loader 绑定一个扩展 | |

Expand Down
4 changes: 2 additions & 2 deletions content/concepts/loaders.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = {
use: [
{ loader: ['style-loader'](/loaders/style-loader)},
{
loader: ['css-loader'](/loaders/css-loader)},
loader: ['css-loader'](/loaders/css-loader),
options: {
modules: true
}
Expand Down Expand Up @@ -100,7 +100,7 @@ T> 尽可能使用 `module.rules`,因为这样可以在源码中减少引用
可选项,你也可以通过 CLI 使用 loader:

```sh
webpack --module-bind jade --module-bind 'css=style!css'
webpack --module-bind jade-loader --module-bind 'css=style-loader!css-loader'
```

这会对 `.jade` 文件使用 `jade-loader`,对 `.css` 文件使用 [`style-loader`](/loaders/style-loader)[`css-loader`](/loaders/css-loader)
Expand Down
2 changes: 2 additions & 0 deletions content/configuration/devtool.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ contributors:
source-map | -- | -- | yes | 原始源码
nosources-source-map | -- | -- | yes | 无源码内容

T> `+` 表示较快,`-` 表示较慢,`o` 表示时间相同

其中一些值适用于开发环境,一些适用于生产环境。对于开发环境,通常希望更快速的 Source Map,需要添加到 bundle 中以增加体积为代价,但是对于生产环境,则希望更精准的 Source Map,需要从 bundle 中分离并独立存在。

W> Chrome 中的 Source Map 有一些问题。[我们需要你的帮助!](https://github.com/webpack/webpack/issues/3165)
Expand Down
11 changes: 10 additions & 1 deletion content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,16 @@ module.exports = {
// 精确控制要显示的 bundle 信息
[devServer](/configuration/dev-server): {
/* TODO */
proxy: { // proxy URLs to backend development server
'/api': 'http://localhost:3000'
},
contentBase: path.join(__dirname, 'public'), // boolean | string | array, static file location
compress: true, // enable gzip compression
historyApiFallback: true, // true for index.html upon 404, object for multiple paths
hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
https: false, // true for self-signed, object for cert authority
noInfo: true, // only errors & warns on hot reload
// ...
},
[plugins](plugins): [
Expand Down
5 changes: 3 additions & 2 deletions content/guides/code-splitting-css.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ webpack 能够用 `ExtractTextWebpackPlugin` 帮助你将 CSS 单独打包,以

安装 [`ExtractTextWebpackPlugin`](/plugins/extract-text-webpack-plugin)
```
npm i --save-dev extract-text-webpack-plugin@beta
npm i --save-dev extract-text-webpack-plugin
```

为了使用这个插件,它需要通过2步被配置到 `webpack.config.js` 文件中。
为了使用这个插件,它需要通过三步被配置到 `webpack.config.js` 文件中。

```diff
+var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
module: {
rules: [{
Expand Down
2 changes: 1 addition & 1 deletion content/guides/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ webpack 不仅仅作为模块打包器存在。如果你要在使用 webpack 或
| 特性 | webpack/webpack | jrburke/requirejs | substack/node-browserify | jspm/jspm-cli | rollup/rollup | brunch/brunch |
|---------|-----------------|-------------------|--------------------------|---------------|---------------|---------------|
| 附加模块按需加载 | **yes** | **yes** | no | [System.import](https://github.com/systemjs/systemjs/blob/master/docs/system-api.md#systemimportmodulename--normalizedparentname---promisemodule) | no | no |
| AMD `define` | **yes** | **yes** | [deamdify](https://github.com/jaredhanson/deamdify) | yes | [rollup-plugin-amd](https://github.com/brunch/uglify-js-brunch) | yes |
| AMD `define` | **yes** | **yes** | [deamdify](https://github.com/jaredhanson/deamdify) | yes | [rollup-plugin-amd](https://github.com/piuccio/rollup-plugin-amd) | yes |
| AMD `require` | **yes** | **yes** | no | yes | no | yes |
| AMD `require` 按需加载 | **yes** | 手动配置 | no | yes | no | no |
| CommonJS `exports` | **yes** | 只包含在 `define`| **yes** | yes | [commonjs-plugin](https://github.com/rollup/rollup-plugin-commonjs) | yes |
Expand Down
8 changes: 6 additions & 2 deletions content/guides/lazy-load-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ class LazilyLoad extends React.Component {
}

componentDidUpdate(previous) {
if (this.props.modules === previous.modules) return null;
this.load();
const shouldLoad = !!Object.keys(this.props.modules).filter((key)=> {
return this.props.modules[key] !== previous.modules[key];
}).length;
if (shouldLoad) {
this.load();
}
}

componentWillUnmount() {
Expand Down
2 changes: 1 addition & 1 deletion content/guides/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ loaders 的压缩模式将在 webpack 3 或更高的版本中被取消。

## `ExtractTextWebpackPlugin` - 大改变

[ExtractTextPlugin](https://github.com/webpack/extract-text-webpack-plugin) 1.0.0 不能在 webpack v2 下工作。 你需要明确地安装 ExtractTextPlugin v2
[ExtractTextPlugin](https://github.com/webpack/extract-text-webpack-plugin) 需要使用版本2,才能在 webpack 2 下正常运行

`npm install --save-dev extract-text-webpack-plugin@beta`

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"fetch": "scripts/fetch.sh",
"init:generated": "mkdirp ./generated/loaders && mkdirp ./generated/plugins ",
"lint": "run-s lint:*",
"lint:links": "hyperlink -r --exclude https://opencollective.com/webpack/*/*/website build/index.html",
"lint:links": "hyperlink -r --exclude https://opencollective.com/webpack/*/*/website build/index.html | ./scripts/check-links.js --skip 10",
"lint:js": "eslint . --ext .js --ext .jsx",
"lint:md": "eslint . --ext .md",
"lint:markdown": "markdownlint --config ./.markdownlintrc **/*.md *.md ./content/**/*.md",
Expand All @@ -56,6 +56,7 @@
"babel-preset-react": "^6.11.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.25.0",
"duplexer": "^0.1.1",
"eslint": "3.6.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-markdown": "^1.0.0-beta.2",
Expand Down Expand Up @@ -88,6 +89,8 @@
"sitemap-static": "^0.3.1",
"style-loader": "^0.13.1",
"tap-min": "^1.1.0",
"tap-parser": "^5.3.3",
"through2": "^2.0.3",
"url-loader": "^0.5.7",
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.1",
Expand Down
44 changes: 44 additions & 0 deletions scripts/check-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env node
// Check piped links while allowing a fixed amount to fail
// Adapted from tap-json.
var parser = require('tap-parser');
var through = require('through2');
var duplexer = require('duplexer');
var minimist = require('minimist');

process.stdin
.pipe(checkLinks())
.pipe(process.stdout);

function checkLinks(args) {
var argv = minimist(process.argv.slice(2));
var skip = argv.skip || 0;

var tap = parser();
var out = through.obj();
var dup = duplexer(tap, out);

var data = [];
var name = null;

tap.on('complete', function(res) {
const failures = res.failures;

if (failures.length > 0) {
console.log(formatFailures(failures));
}

// Fail hard only if over skip threshold
if (failures.length > skip) {
process.exit(1);
}
});

return dup;
}

function formatFailures(failures) {
return failures.map(function(failure) {
return failure.name + '\n' + failure.diag.actual + ' at ' + failure.diag.at;
}).join('\n\n');
}
Loading

0 comments on commit 26d8f93

Please sign in to comment.