From b44dd98ed2bb286c49125774c8202c9eb2db524d Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Fri, 16 Jun 2017 08:47:58 +0200 Subject: [PATCH 1/7] Remove unnecessary new line Signed-off-by: Bruno Lesieur --- docs/en/advanced/lazy-loading.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/en/advanced/lazy-loading.md b/docs/en/advanced/lazy-loading.md index 8b13ca4d6..a6465b094 100644 --- a/docs/en/advanced/lazy-loading.md +++ b/docs/en/advanced/lazy-loading.md @@ -2,8 +2,7 @@ When building apps with a bundler, the JavaScript bundle can become quite large, and thus affect the page load time. It would be more efficient if we can split each route's components into a separate chunk, and only load them when the route is visited. -Combining Vue's [async component feature](http://vuejs.org/guide/components.html#Async-Components) and webpack's [code splitting feature](https://webpack.js.org/guides/code-splitting-async/), it's trivially easy to -lazy-load route components. +Combining Vue's [async component feature](http://vuejs.org/guide/components.html#Async-Components) and webpack's [code splitting feature](https://webpack.js.org/guides/code-splitting-async/), it's trivially easy to lazy-load route components. First, an async component can be defined as a factory function that returns a Promise (which should resolve to the component itself): From ca0d38a2be1892f321538a78caaf28238cabad5a Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Sat, 17 Jun 2017 17:10:42 +0200 Subject: [PATCH 2/7] Update dev From 2ef49cc9ecee1275600d96a2b983bc902cebf6ae Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Thu, 13 Jul 2017 14:16:07 +0200 Subject: [PATCH 3/7] Add native Node.js server configuration Signed-off-by: Bruno Lesieur --- docs/en/essentials/history-mode.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/en/essentials/history-mode.md b/docs/en/essentials/history-mode.md index 6e543a509..2834e9da0 100644 --- a/docs/en/essentials/history-mode.md +++ b/docs/en/essentials/history-mode.md @@ -40,7 +40,31 @@ location / { } ``` -#### Node.js (Express) +#### Native Node.js + +```js +var http = require("http"), + fs = require("fs"), + httpPort = 80; + +http.createServer(function (req, res) { + fs.readFile("index.htm", "utf-8", function (err, content) { + if (err) { + console.log('We cannot open "index.htm" file.'); + } + + res.writeHead(200, { + "Content-Type": "text/html; charset=utf-8" + }); + + res.end(content); + }); +}).listen(httpPort, function () { + console.log("Server listening on: http://localhost:%s", httpPort); +}); +``` + +#### Express with Node.js For Node.js/Express, consider using [connect-history-api-fallback middleware](https://github.com/bripkens/connect-history-api-fallback). @@ -95,4 +119,4 @@ const router = new VueRouter({ }) ``` -Alternatively, if you are using a Node.js server, you can implement the fallback by using the router on the server side to match the incoming URL and respond with 404 if no route is matched. +Alternatively, if you are using a Node.js server, you can implement the fallback by using the router on the server side to match the incoming URL and respond with 404 if no route is matched. Check out its [Vue server side usage documentation](https://ssr.vuejs.org/en/) for more informations. From bb3e73e21508019195a170edd895966ef00429fe Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Thu, 13 Jul 2017 14:27:19 +0200 Subject: [PATCH 4/7] Remove `;` and add `const` like other code examples. Signed-off-by: Bruno Lesieur --- docs/en/essentials/history-mode.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/essentials/history-mode.md b/docs/en/essentials/history-mode.md index 2834e9da0..4e15c41de 100644 --- a/docs/en/essentials/history-mode.md +++ b/docs/en/essentials/history-mode.md @@ -43,24 +43,24 @@ location / { #### Native Node.js ```js -var http = require("http"), - fs = require("fs"), - httpPort = 80; +const http = require("http"); +const fs = require("fs"); +const httpPort = 80; http.createServer(function (req, res) { fs.readFile("index.htm", "utf-8", function (err, content) { if (err) { - console.log('We cannot open "index.htm" file.'); + console.log('We cannot open "index.htm" file.') } res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" }); - res.end(content); + res.end(content) }); }).listen(httpPort, function () { - console.log("Server listening on: http://localhost:%s", httpPort); + console.log("Server listening on: http://localhost:%s", httpPort) }); ``` From 7003dcbf1af9265cf284fda6a5690a76531c4f2c Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Thu, 13 Jul 2017 14:30:12 +0200 Subject: [PATCH 5/7] Remove more ";" Signed-off-by: Bruno Lesieur --- docs/en/essentials/history-mode.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/en/essentials/history-mode.md b/docs/en/essentials/history-mode.md index 4e15c41de..d93fa1529 100644 --- a/docs/en/essentials/history-mode.md +++ b/docs/en/essentials/history-mode.md @@ -43,9 +43,9 @@ location / { #### Native Node.js ```js -const http = require("http"); -const fs = require("fs"); -const httpPort = 80; +const http = require("http") +const fs = require("fs") +const httpPort = 80 http.createServer(function (req, res) { fs.readFile("index.htm", "utf-8", function (err, content) { @@ -55,13 +55,13 @@ http.createServer(function (req, res) { res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" - }); + }) res.end(content) - }); + }) }).listen(httpPort, function () { console.log("Server listening on: http://localhost:%s", httpPort) -}); +}) ``` #### Express with Node.js From a7c49064565de0b53d6c8fd2271c918cfc9c2e49 Mon Sep 17 00:00:00 2001 From: Bruno Lesieur Date: Mon, 17 Jul 2017 08:15:30 +0200 Subject: [PATCH 6/7] Arrow function style added Signed-off-by: Bruno Lesieur --- docs/en/essentials/history-mode.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/essentials/history-mode.md b/docs/en/essentials/history-mode.md index d93fa1529..aecc3cb19 100644 --- a/docs/en/essentials/history-mode.md +++ b/docs/en/essentials/history-mode.md @@ -47,8 +47,8 @@ const http = require("http") const fs = require("fs") const httpPort = 80 -http.createServer(function (req, res) { - fs.readFile("index.htm", "utf-8", function (err, content) { +http.createServer((req, res) => { + fs.readFile("index.htm", "utf-8", (err, content) => { if (err) { console.log('We cannot open "index.htm" file.') } @@ -59,7 +59,7 @@ http.createServer(function (req, res) { res.end(content) }) -}).listen(httpPort, function () { +}).listen(httpPort, () => { console.log("Server listening on: http://localhost:%s", httpPort) }) ``` From 8f7295e132a61b60420bbc51cbcfdc6689dcf316 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 17 Jul 2017 16:24:07 +0200 Subject: [PATCH 7/7] Update history-mode.md --- docs/en/essentials/history-mode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/essentials/history-mode.md b/docs/en/essentials/history-mode.md index aecc3cb19..76d9b13c9 100644 --- a/docs/en/essentials/history-mode.md +++ b/docs/en/essentials/history-mode.md @@ -119,4 +119,4 @@ const router = new VueRouter({ }) ``` -Alternatively, if you are using a Node.js server, you can implement the fallback by using the router on the server side to match the incoming URL and respond with 404 if no route is matched. Check out its [Vue server side usage documentation](https://ssr.vuejs.org/en/) for more informations. +Alternatively, if you are using a Node.js server, you can implement the fallback by using the router on the server side to match the incoming URL and respond with 404 if no route is matched. Check out the [Vue server side rendering documentation](https://ssr.vuejs.org/en/) for more information.