Skip to content

June 2018 #146

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 57 commits into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
91a46ed
Update unit-testing-vue-components.md (#1623)
38elements May 11, 2018
20e461a
Fixed a typo (#1625)
aabounegm May 13, 2018
aa3a92e
fix a typo (#1627)
May 14, 2018
1bf4628
Update v-for list example (#1628)
chipit24 May 14, 2018
f247d17
fix: code snippet language (close #1617) (#1626)
hmatalonga May 14, 2018
0336b80
Update todo-list-example for a11y (#1630)
chipit24 May 17, 2018
7c12895
change NODE_ENV to follow recommendations from webpack (#1622)
parkourben99 May 17, 2018
9244cfc
note that modes are not available in transition groups, fixes #1619
chrisvfritz May 17, 2018
19733d5
add examples for in API doc
chrisvfritz May 17, 2018
e959d38
add comparison note about react-like libraries
chrisvfritz May 17, 2018
418d7f3
Update components.md (#1632)
artiomgiza May 17, 2018
28ad8a1
cookbook entry for storage (#1550)
cfjedimaster May 18, 2018
a78885d
Update index.md (#1634)
Alex-Sokolov May 18, 2018
44d73a1
docs(guide/comparison): correct size stat of Angular CLI project (#1638)
trotyl May 21, 2018
3d1fdd8
Update client-side-storage.md (#1640)
Alex-Sokolov May 21, 2018
5bd7be0
Update creating-custom-scroll-directives.md (#1639)
Alex-Sokolov May 21, 2018
ef9b64e
chore: update ad code
yyx990803 May 22, 2018
bf5a331
remove unnecessary word 'know' (#1641)
pipopotamasu May 22, 2018
9e977cd
Updated broken links for the Vue Test Utils documentation. (#1643)
May 22, 2018
eee7fcd
Reorganize component props to introduce prop types earlier, fixes #16…
chrisvfritz May 25, 2018
dc9b6cb
First stab at SFC to npm documentation (#1558)
mgdodge May 25, 2018
256c51b
Rename packaing-sfc-for-npm.md to packaging-sfc-for-npm.md (#1652)
Alex-Sokolov May 25, 2018
c2be312
Update link in comparison guide (#1653)
flaviocopes May 28, 2018
8e08656
chore: update vue version
yyx990803 Jun 1, 2018
b025983
Fix link to docs on custom inputs (#1660)
alastairs Jun 3, 2018
055629e
correct wrong link (#1661)
byog Jun 3, 2018
f3d9557
Feature/vuemeetups (#1665)
bencodezen Jun 3, 2018
7cb981c
Added details about Lifecycle Hooks (#1664)
Knogobert Jun 3, 2018
ec38b56
improve comparisons react scaling down section
chrisvfritz Jun 3, 2018
fda94a9
add text versions of image code examples
chrisvfritz Jun 3, 2018
b0d792b
remove extra comma in components
chrisvfritz Jun 3, 2018
cffbc40
TypeScript project generation in @vue/cli 3.0 (#1668)
k3a Jun 3, 2018
4a734c2
chore: update sponsors
yyx990803 Jun 4, 2018
40e5066
Merge remote-tracking branch 'upstream/master' into june-2018
MachinisteWeb Jun 10, 2018
8d7aec7
Merge branch 'master' into june-2018
MachinisteWeb Jun 10, 2018
9e3d2c2
Sylvain and Forresst feedbacks
MachinisteWeb Jun 11, 2018
fa7fe2f
chore: update sponsors
yyx990803 Jun 11, 2018
49ffe8e
update CLI docs link
yyx990803 Jun 11, 2018
aeebd0e
add Scrimba links for preview
yyx990803 Jun 11, 2018
1bfac64
@forrestt and @RaisonBlue feedback
MachinisteWeb Jun 12, 2018
933dfb4
Feedback of @rspt
MachinisteWeb Jun 12, 2018
1a16aa2
Fix example indentation in the Unit Testing Vue Components recipe (#1…
lex111 Jun 16, 2018
f55d693
Update debugging-in-vscode.md (#1662)
Alex-Sokolov Jun 16, 2018
912d564
Added link to vuemeetups.org to the ecosystem drop-down menu on websi…
rdytogokev Jun 16, 2018
4fe97c4
Correct mistake of Migration from Vue 1.x (#1686)
CyanSalt Jun 16, 2018
171e198
Fix code style in Form Validation recipe (#1682)
lex111 Jun 17, 2018
779c5d5
Fix code style in Client-Side Storage recipe (#1690)
lex111 Jun 17, 2018
9969aad
[Doc EN]: `typescript.md` (#1679)
MachinisteWeb Jun 17, 2018
edbbf1a
[cookbook] Dockerize Vue.js App (#1483)
fabriziocucci Jun 18, 2018
e93b837
Update debugging-in-vscode.md (#1663)
Alex-Sokolov Jun 18, 2018
53b11fb
remove outdated information about polymer from comparison
chrisvfritz Jun 26, 2018
9fa45f0
update React comparison status
yyx990803 Jun 28, 2018
d53d326
Merge remote-tracking branch 'upstream/master' into june-2018
MachinisteWeb Jun 30, 2018
c13cd8b
Merge branch 'june-2018' of https://github.com/vuejs-fr/vuejs.org int…
MachinisteWeb Jun 30, 2018
294d54e
Remove extra part
MachinisteWeb Jun 30, 2018
45069b5
Remove extra content from api/index.md
MachinisteWeb Jun 30, 2018
4da2fcc
Remove extra merge
MachinisteWeb Jun 30, 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
2 changes: 1 addition & 1 deletion src/v2/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2533,4 +2533,4 @@ Used to denote a `<template>` element as a scoped slot, which is replaced by [`s

## Rendu côté serveur

- Veuillez vous référer à la [documentation du package vue-server-renderer](https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer).
- Veuillez vous référer à la [documentation du package vue-server-renderer](https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer).
4 changes: 2 additions & 2 deletions src/v2/cookbook/avoiding-memory-leaks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ new Vue({
methods: {
initializeChoices: function () {
let list = []
// lets load up our select with many choices
// lets load up our select with many choices
// so it will use a lot of memory
for (let i = 0; i < 1000; i++) {
list.push({
Expand Down Expand Up @@ -123,7 +123,7 @@ new Vue({

## Details about the Value

Memory management and performance testing can easily be neglected in the excitement of shipping quickly, however, keeping a small memory footprint is still important to your overall user experience.
Memory management and performance testing can easily be neglected in the excitement of shipping quickly, however, keeping a small memory footprint is still important to your overall user experience.

Consider the types of devices your users may be using and what their normal flow will be. Could they use memory constrained laptops or mobile devices? Do your users typically do lots of in-application navigation? If either of these are true, then good memory management practices can help you avoid the worst case scenario of crashing a user’s browser. Even if neither of these are true, you can still potentially have degradation of performance over extended usage of your app if you are not careful.

Expand Down
47 changes: 28 additions & 19 deletions src/v2/cookbook/client-side-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ This example has one form field bound to a Vue value called `name`. Here's the J

``` js
const app = new Vue({
el:'#app',
el: '#app',
data: {
name:''
name: ''
},
mounted() {
if(localStorage.name) this.name = localStorage.name;
if (localStorage.name) {
this.name = localStorage.name;
}
},
watch: {
name(newName) {
Expand All @@ -37,7 +39,7 @@ const app = new Vue({
});
```

Focus on the `mounted` and `watch` parts. We use `mounted` to handle loading the value from localStorage. To handle writing the data base, we watch the `name` value and on change, immediately write it.
Focus on the `mounted` and `watch` parts. We use `mounted` to handle loading the value from localStorage. To handle writing the data base, we watch the `name` value and on change, immediately write it.

You can run this yourself here:

Expand Down Expand Up @@ -75,12 +77,16 @@ Now we've got two fields (again, bound to a Vue instance) but now there is the a
const app = new Vue({
el:'#app',
data: {
name:'',
age:0
name: '',
age: 0
},
mounted() {
if(localStorage.name) this.name = localStorage.name;
if(localStorage.age) this.age = localStorage.age;
if (localStorage.name) {
this.name = localStorage.name;
}
if (localStorage.age) {
this.age = localStorage.age;
}
},
methods: {
persist() {
Expand All @@ -106,30 +112,30 @@ As mentioned above, Local Storage only works with simple values. To store more c
<h2>Cats</h2>
<div v-for="(cat,n) in cats">
<p>
<span class="cat">{{cat}}</span> <button @click="removeCat(n)">Remove</button>
<span class="cat">{{ cat }}</span> <button @click="removeCat(n)">Remove</button>
</p>
</div>

<p>
<input v-model="newCat">
<input v-model="newCat">
<button @click="addCat">Add Cat</button>
</p>

</div>
```

This "app" consists of a simple list on top (with a button to remove a cat) and a small form at the bottom to add a new cat. Now let's look at the JavaScript.

``` js
const app = new Vue({
el:'#app',
el: '#app',
data: {
cats:[],
newCat:null
cats: [],
newCat: null
},
mounted() {
if(localStorage.getItem('cats')) {

if (localStorage.getItem('cats')) {
try {
this.cats = JSON.parse(localStorage.getItem('cats'));
} catch(e) {
Expand All @@ -140,13 +146,16 @@ const app = new Vue({
methods: {
addCat() {
// ensure they actually typed something
if(!this.newCat) return;
if (!this.newCat) {
return;
}

this.cats.push(this.newCat);
this.newCat = '';
this.saveCats();
},
removeCat(x) {
this.cats.splice(x,1);
this.cats.splice(x, 1);
this.saveCats();
},
saveCats() {
Expand Down
20 changes: 15 additions & 5 deletions src/v2/cookbook/debugging-in-vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ Go to `config/index.js` and find the `devtool` property. Update it to:
devtool: 'source-map',
```

With Vue CLI 3 you need set `devtool` property inside `vue.config.js`:

```js
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
```

### Launching the Application from VS Code

Click on the Debugging icon in the Activity Bar to bring up the Debug view, then click on the gear icon to configure a launch.json file, selecting **Chrome** for the environment. Replace content of the generated launch.json with the following two configurations:
Expand Down Expand Up @@ -53,19 +63,19 @@ Click on the Debugging icon in the Activity Bar to bring up the Debug view, then

1. Set a breakpoint in **src/components/HelloWorld.vue** on `line 90` where the `data` function returns a string.

![Breakpoint Renderer](/images/breakpoint_set.png)
![Breakpoint Renderer](/images/breakpoint_set.png)

2. Open your favorite terminal at the root folder and serve the app using Vue CLI:

```
npm start
```
```
npm start
```

3. Go to the Debug view, select the **'vuejs: chrome'** configuration, then press F5 or click the green play button.

4. Your breakpoint should now be hit as the new instance of Chrome opens `http://localhost:8080`.

![Breakpoint Hit](/images/breakpoint_hit.png)
![Breakpoint Hit](/images/breakpoint_hit.png)

## Alternative Patterns

Expand Down
134 changes: 134 additions & 0 deletions src/v2/cookbook/dockerize-vuejs-app.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
title: Dockerize Vue.js App (EN)
type: cookbook
order: 13
---

## Simple Example

<p>Cette page est en cours de traduction. Pour nous aider, vous pouvez participer sur <a href="https://github.com/vuejs-fr/vuejs.org" target="_blank">le dépôt GitHub dédié de Vuejs-FR</a>.</p>So you built your first Vue.js app using the amazing [Vue.js webpack template](https://github.com/vuejs-templates/webpack) and now you really want to show off with your colleagues by demonstrating that you can also run it in a Docker container.</p>

Let's start by creating a `Dockerfile` in the root folder of our project:

```docker
FROM node:9.11.1-alpine

# install simple http server for serving static content
RUN npm install -g http-server

# make the 'app' folder the current working directory
WORKDIR /app

# copy both 'package.json' and 'package-lock.json' (if available)
COPY package*.json ./

# install project dependencies
RUN npm install

# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .

# build app for production with minification
RUN npm run build

EXPOSE 8080
CMD [ "http-server", "dist" ]
```

It may seem reduntant to first copy `package.json` and `package-lock.json` and then all project files and folders in two separate steps but there is actually [a very good reason for that](http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/) (spoiler: it allows us to take advantage of cached Docker layers).

Now let's build the Docker image of our Vue.js app:

```bash
docker build -t vuejs-cookbook/dockerize-vuejs-app .
```

Finally, let's run our Vue.js app in a Docker container:

```bash
docker run -it -p 8080:8080 --rm --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
```

We should be able to access our Vue.js app on `localhost:8080`.

## Real-World Example

In the previous example, we used a simple, zero-configuration command-line [http server](https://github.com/indexzero/http-server) to serve our Vue.js app which is perfectly ok for quick prototyping and _may_ even be ok for simple production scenarios. After all, the documentation says:

> It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development, and learning.

Nevertheless, for realistically complex production use cases, it may be wiser to stand on the shoulders of some giant like [NGINX](https://www.nginx.com/) or [Apache](https://httpd.apache.org/) and that is exactly what we are going to do next: we are about to leverage NGINX to serve our vue.js app because it is considered to be one of the most performant and battle-tested solutions out there.

Let's refactor our `Dockerfile` to use NGINX:

```docker
# build stage
FROM node:9.11.1-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# production stage
FROM nginx:1.13.12-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
```

Ok, let's see what's going on here:
* we have split our original `Dockerfile` in multiple stages by leveraging the Docker [multi-stage builds](https://docs.docker.com/develop/develop-images/multistage-build/) feature;
* the first stage is responsible for building a production-ready artifact of our Vue.js app;
* the second stage is responsible for serving such artifact using NGINX.

Now let's build the Docker image of our Vue.js app:

```bash
docker build -t vuejs-cookbook/dockerize-vuejs-app .
```

Finally, let's run our Vue.js app in a Docker container:

```bash
docker run -it -p 8080:80 --rm --name dockerize-vuejs-app-1 vuejs-cookbook/dockerize-vuejs-app
```

We should be able to access our Vue.js app on `localhost:8080`.

## Additional Context

If you are reading this cookbook, chances are you already know why you decided to dockerize your Vue.js app. But if you simply landed on this page after hitting the Google's `I'm feeling lucky` button, let me share with you a couple of good reasons for doing that.

Today's modern trend is to build applications using the [Cloud-Native](https://pivotal.io/cloud-native) approach which revolves mainly around the following buzzwords:
* Microservices
* DevOps
* Continuous Delivery

Let's see how these concepts actually affect our decision of dockerizing our Vue.js app.

### Effects of Microservices

By adopting the [microservices architectural style](https://martinfowler.com/microservices/), we end up building a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms. These services are built around business capabilities and independently deployable by fully automated deployment machinery.

So, committing to this architectural approach most of the time implies developing and delivering our front-end as an independent service.

### Effects of DevOps

The adoption of [DevOps](https://martinfowler.com/bliki/DevOpsCulture.html) culture, tools and agile engineering practices has, among other things, the nice effect of increasing the collaboration between the roles of development and operations. One of the main problem of the past (but also today in some realities) is that the dev team tended to be uninterested in the operation and maintenance of a system once it was handed over to the ops team, while the latter tended to be not really aware of the system's business goals and, therefore, reluctant in satisfying the operational needs of the system (also referred to as "whims of developers").

So, delivering our Vue.js app as a Docker image helps reducing, if not removing entirely, the difference between running the service on a deveveloper's laptop, the production environment or any environment we may think of.

### Effects of Continuous Delivery

By leveraging the [Continuous Delivery](https://martinfowler.com/bliki/ContinuousDelivery.html) discipline we build our software in a way that it can potentially be released to production at any time. Such engineering practice is enabled by means of what is normally called [continuous delivery pipeline](https://martinfowler.com/bliki/DeploymentPipeline.html). The purpose of a continuous delivery pipeline is to split our build into stages (e.g. compilation, unit tests, integration tests, performance tests, etc.) and let each stage verify our build artifact whenever our software changes. Ultimately, each stage increases our confidence in the production readiness of our build artifact and, therefore, reduces the risk of breaking things in production (or any other environment for that matters).

So, creating a Docker image for our Vue.js app is a good choice here because that would represent our final build artifact, the same artifact that would be verified against our continuous delivery pipeline and that could potentially be released to production with confidence.

## Alternative Patterns

If your company is not into Docker and Kubernetes just yet or you simply want to get your MVP out the door, maybe dockerizing your Vue.js app is not what you need.

Common alternatives are:
* leveraging an all-in-one platform like [netlify](https://www.netlify.com/);
* hosting your SPA on [Amazon S3](https://aws.amazon.com/s3/) and serving it with [Amazon CloudFront](https://aws.amazon.com/cloudfront/) (see [this](https://serverless-stack.com/chapters/deploy-the-frontend.html) link for a detailed guide).
Loading