Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs-templates/pwa
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.0
Choose a base ref
...
head repository: vuejs-templates/pwa
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: development
Choose a head ref

Commits on May 31, 2017

  1. update cacheId

    li.li committed May 31, 2017
    Copy the full SHA
    48b8cb6 View commit details

Commits on Jul 14, 2017

  1. Put hotMiddleware before proxyMiddleware in dev server

    Nicholas Baroni committed Jul 14, 2017
    Copy the full SHA
    d208a70 View commit details

Commits on Aug 14, 2017

  1. Copy the full SHA
    fd3c608 View commit details

Commits on Aug 25, 2017

  1. bug(gitter): remove deprecated gitter link for community chat (#75)

    * bug(chat): remove gitter chat link - update to community chat
    
     Changed to remove deprecated gitter and point to: http://chat.vuejs.org/
    
    * Update Hello.vue
    MarkPieszak authored and addyosmani committed Aug 25, 2017
    Copy the full SHA
    816cd2a View commit details

Commits on Aug 29, 2017

  1. Copy the full SHA
    27f3679 View commit details
  2. fix ci config (#76)

    gucong3000 authored and addyosmani committed Aug 29, 2017
    Copy the full SHA
    4d6a02b View commit details

Commits on Oct 14, 2017

  1. Prevent syntax error in Internet Explorer

    Old versions of Internet Explorer do not support `const`.
    maoberlehner committed Oct 14, 2017
    Copy the full SHA
    6ef28f1 View commit details
  2. update dependencies

    - vue 2.5
    - vue router 3.0
    - webpack 3
    - update all dependencies
    Ffloriel committed Oct 14, 2017
    Copy the full SHA
    f374b87 View commit details
  3. bump version 2.1.0

    Ffloriel committed Oct 14, 2017
    Copy the full SHA
    13147e3 View commit details

Commits on Oct 15, 2017

  1. Copy the full SHA
    b3c95aa View commit details

Commits on Oct 26, 2017

  1. Merge pull request #93 from Ffloriel/update-dependencies

    Update dependencies
    anubhav7495 authored Oct 26, 2017
    Copy the full SHA
    0b55c08 View commit details
  2. Merge pull request #88 from sudo-suhas/refactor_use_const_let

    Use const/let instead of var with strict mode
    anubhav7495 authored Oct 26, 2017
    Copy the full SHA
    e943540 View commit details

Commits on Oct 30, 2017

  1. fix Es6 code issue.

    This file is not transpiled, so we should stick to ES5
    zhenhappy authored Oct 30, 2017
    Copy the full SHA
    fd36b72 View commit details

Commits on Nov 9, 2017

  1. Copy the full SHA
    72f43be View commit details
  2. Copy the full SHA
    2012635 View commit details

Commits on Nov 12, 2017

  1. Add licence (close #110)

    LinusBorg authored Nov 12, 2017
    Copy the full SHA
    5996926 View commit details

Commits on Nov 13, 2017

  1. Merge pull request #111 from LinusBorg/patch-1

    Add licence (close #110)
    anubhav7495 authored Nov 13, 2017
    Copy the full SHA
    92dc0bd View commit details

Commits on Nov 14, 2017

  1. Merge pull request #53 from rhythnic/middleware-order

    Put hotMiddleware before proxyMiddleware in dev server
    jeffposnick authored Nov 14, 2017
    Copy the full SHA
    92e0270 View commit details
  2. Merge pull request #28 from lili21/feat/cache-id

    update cacheId
    jeffposnick authored Nov 14, 2017
    Copy the full SHA
    0316175 View commit details
  3. Merge pull request #94 from maoberlehner/master

    Prevent syntax error in Internet Explorer
    jeffposnick authored Nov 14, 2017
    Copy the full SHA
    f972fc9 View commit details
  4. Merge pull request #105 from zhenhappy/master

    fix Es6 code issue.
    jeffposnick authored Nov 14, 2017
    Copy the full SHA
    99acbac View commit details

Commits on Nov 26, 2017

  1. Copy the full SHA
    c214a06 View commit details

Commits on Nov 27, 2017

  1. Merge pull request #115 from ahus1/cache_limit

    add section why cache limitation is necessary with examples #70
    jeffposnick authored Nov 27, 2017
    Copy the full SHA
    3d83b26 View commit details
  2. Cosmetic change.

    jeffposnick committed Nov 27, 2017
    Copy the full SHA
    e28d5f6 View commit details

Commits on Nov 28, 2017

  1. Add a Contributing section (#114)

    jeffposnick authored and addyosmani committed Nov 28, 2017
    Copy the full SHA
    b3e4b77 View commit details
  2. Copy the full SHA
    3ccedb7 View commit details

Commits on Nov 29, 2017

  1. Update meta.js

    removed trailing comma
    samkitano authored Nov 29, 2017
    Copy the full SHA
    802bd0a View commit details
  2. Merge pull request #123 from samkitano/development

    Update meta.js
    jeffposnick authored Nov 29, 2017
    Copy the full SHA
    d03f096 View commit details

Commits on Dec 4, 2017

  1. Switch to uglifyjs-webpack-plugin

    This plugin uses UglifyJS v3 (`uglify-es`) to minify JavaScript. It can be used
    to minify ES6.
    sudo-suhas committed Dec 4, 2017
    Copy the full SHA
    5da8acc View commit details
  2. Merge pull request #128 from sudo-suhas/uglifyjs-plugin

    Switch to uglifyjs-webpack-plugin
    jeffposnick authored Dec 4, 2017
    Copy the full SHA
    694af84 View commit details

Commits on Dec 11, 2017

  1. Copy the full SHA
    80d4442 View commit details
  2. Merge pull request #132 from sudo-suhas/doc-init-development

    Update usage in readme to init from development branch
    jeffposnick authored Dec 11, 2017
    Copy the full SHA
    32b20a5 View commit details

Commits on Dec 19, 2017

  1. Copy the full SHA
    8dedc0d View commit details
  2. Merge pull request #137 from sudo-suhas/docs-babel-preset-env

    Document babel target env configuration
    jeffposnick authored Dec 19, 2017
    Copy the full SHA
    2cecb0f View commit details

Commits on Dec 29, 2017

  1. Copy the full SHA
    5f8f9d3 View commit details

Commits on Jan 2, 2018

  1. Merge pull request #142 from sudo-suhas/engine-node-6

    Change engine>node{4 => 6} for template
    jeffposnick authored Jan 2, 2018
    Copy the full SHA
    17022a5 View commit details

Commits on Jun 11, 2018

  1. Maintenance mode message (#191)

    R: @addyosmani, whom I discussed this with out-of-band.
    CC: @yyx990803, in case there are any concerns, specifically about the readiness of pointing people to `vue-cli` 3.0 as an alternative at this point.
    
    I wanted to reflect the reality of the current state of this template, as the `pwa` template that ships with `vue-cli` is where our efforts will be devoted moving forward.
    
    Fixes #190
    jeffposnick authored and addyosmani committed Jun 11, 2018
    Copy the full SHA
    cdf3b0e View commit details
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2013-present, Yuxi (Evan) You

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Maintenance Mode
**The code in this repo is in maintenance mode, with limited plans for future changes. Our focus moving forward is adding PWA support to [Vue CLI 3.0](https://github.com/vuejs/vue-cli/blob/dev/README.md), using its new [`pwa` plugin](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa). We encourage this work to be used for new projects as it is being actively developed. If you have issues with the current codebase, give the new version a spin and let us know what you think.**

# vue-pwa-boilerplate

> A full-featured [PWA](https://developers.google.com/web/progressive-web-apps/) template with webpack, hot-reload, lint-on-save, unit testing & css extraction.
@@ -12,16 +15,32 @@

This is a project template for [vue-cli](https://github.com/vuejs/vue-cli). **It is recommended to use npm 3+ or [yarn](https://yarnpkg.com) for a more efficient dependency tree.**

``` bash
```bash
$ npm install -g vue-cli
$ vue init pwa my-project
$ cd my-project
$ npm install
$ npm run dev
```

This will scaffold the project using the `master` branch. If you wish to use the latest version of the PWA template, do the following instead:

``` bash
$ vue init pwa#development my-project
```

:warning: **The `development` branch is not considered stable and can contain bugs or not build at all, so use at your own risk.**

If port 8080 is already in use on your machine you must change the port number in `/config/index.js`. Otherwise `npm run dev` will fail.

## What's not Included

* You should configure your web server to add HTTP headers to prevent caching of critical service worker files.
If you don't do this, [browsers might cache the content for up to 24 hours](https://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours/38854905#38854905).
In addition, you should add HTTP headers to prevent the contents of the static folder to be cached unintentionally long.

See ["Configuring your Web server to prevent caching"](docs/prevent_caching.md) in the docs for more information.

## What's Included

* Service Worker precaching of application shell + static assets (prod)
@@ -38,7 +57,7 @@ If port 8080 is already in use on your machine you must change the port number i
- Source maps

- `npm run build`: Production ready build.
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
- JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony).
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
- All static assets compiled with version hashes for efficient long-term caching, and a production `index.html` is auto-generated with proper URLs to these generated assets.
@@ -60,6 +79,16 @@ If port 8080 is already in use on your machine you must change the port number i

You can fork this repo to create your own boilerplate, and use it with `vue-cli`:

``` bash
```bash
vue init username/repo my-project
```

## Contributing

This project is a modified copy of the [`vue-webpack-boilerplate`](https://github.com/vuejs-templates/webpack) template.

While we welcome contributions from the community, please note that changes to configuration that is shared between this project and `vue-webpack-boilerplate` should be made against `vue-webpack-boilerplate` *first*.

Once the [upstream](https://stackoverflow.com/a/2739476/385997) PR is merged, please file an additional PR against this project making the equivalent changes. This will help ensure that the shared configuration does not diverge too much.

Any changes that are specific to this project—related to service workers, or other PWA functionality—do not need an equivalent upstream PR.
8 changes: 7 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
machine:
node:
version: 6
version: stable

dependencies:
pre:
- sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
- sudo apt-get update
- sudo apt-get install google-chrome-stable

test:
override:
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

- [Project Structure](structure.md)
- [Build Commands](commands.md)
- [Babel Configuration](babel.md)
- [Linter Configuration](linter.md)
- [Pre-Processors](pre-processors.md)
- [Handling Static Assets](static.md)
22 changes: 22 additions & 0 deletions docs/babel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Babel Configuration

This boilerplate uses [`babel-preset-env`](https://www.npmjs.com/package/babel-preset-env) for configuring babel. You can read more about it here - http://2ality.com/2017/02/babel-preset-env.html.

> A Babel preset that compiles ES2015+ down to ES5 by automatically determining the Babel plugins and polyfills you need based on your targeted browser or runtime environments.
It uses [`browserslist`](https://github.com/ai/browserslist) to parse this information, so we can use any [valid query format supported by `browserslist`](https://github.com/ai/browserslist#queries).

However there is a caveat. `browserslist` recommends defining the target in a common place like `package.json` or in a `.browserslistrc` config file. This allows tools like [`autoprefixer`](https://github.com/postcss/autoprefixer) and [`eslint-plugin-compat`](https://github.com/amilajack/eslint-plugin-compat) to share the config. For this template, `browserslist` is configured in the `package.json`:

```json
{
"...": "...",
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
```

But the latest stable release of `babel-preset-env`, `v1.6.1` does not support loading the config from `package.json`. So the target environment is repeated in `.babelrc`. If you wish to change your target environment, please be sure to update both `package.json` and `.babelrc`. Note that this has been fixed in the beta version([`@babel/preset-env@7.0.0-beta.34`](https://github.com/babel/babel/tree/master/packages/babel-preset-env)) and the template will be updated once it is out of beta.
4 changes: 3 additions & 1 deletion docs/backend.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,9 @@ If you are building a purely-static app (one that is deployed separately from th
Let's take a look at the default `config/index.js`:

``` js
var path = require('path')
'use strict'

const path = require('path')

module.exports = {
build: {
2 changes: 1 addition & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ All build commands are executed via [NPM Scripts](https://docs.npmjs.com/misc/sc

> Build assets for production. See [Integrating with Backend Framework](backend.md) for more details.
- JavaScript minified with [UglifyJS](https://github.com/mishoo/UglifyJS2).
- JavaScript minified with [UglifyJS v3](https://github.com/mishoo/UglifyJS2/tree/harmony).
- HTML minified with [html-minifier](https://github.com/kangax/html-minifier).
- CSS across all components extracted into a single file and minified with [cssnano](https://github.com/ben-eb/cssnano).
- All static assets compiled with version hashes for efficient long-term caching, and a production `index.html` is auto-generated with proper URLs to these generated assets.
2 changes: 1 addition & 1 deletion docs/prerender.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ npm install --save-dev prerender-spa-plugin

```js
// This line should go at the top of the file where other 'imports' live in
var PrerenderSpaPlugin = require('prerender-spa-plugin')
const PrerenderSpaPlugin = require('prerender-spa-plugin')
```

3. Configure it in the `plugins` array (also in **build/webpack.prod.conf.js**):
63 changes: 63 additions & 0 deletions docs/prevent_caching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Configuring your Web server to prevent caching

## Why you want to do this

You should configure your web server to add HTTP headers to prevent caching of critical service worker files.
If you don't do this, [browsers might cache the content for up to 24 hours](https://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours/38854905#38854905).

In addition, you should add HTTP headers to prevent the contents of the static folder to be cached unintentionally long.

## Mechanisms at work

### Service worker

When you run the production build and deploy the application to a web server, the browser will call the service worker on the first visit and will download and cache all resources.
When the browser accesses the site a second time, it will use the cached resources.
To notice changes in your app it is crucial that the browser downloads the latest version `service-worker.js` from your server.
The browser will only do this when the [Cache-Control](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching) header associated with `service-worker.js` indicates that a previous download has expired or [24 hours have passed](https://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours/38854905#38854905).
If a new service worker is available, it will download the new contents in the background.
Once the download is complete, the default behavior is that the new content will be shown on the next visit of the site.
You can change the template's [`service-worker-prod.js`](../template/build/service-worker-prod.js) to display the message to the user to reload the page, or issue a `window.location.reload()` automatically to trigger an update depending on your application's needs.

Depending on your setup, you might want to have a short caching time for your service worker or no caching at all.
At minimum, you should add caching headers to disable or minimize caching for `service-worker.js` and `index.html`.

### The static folder

The folder [`static`](../template/static) contains the manifest and the favicons of your app.

You should limit or disable caching for all files in this folder to ensure users have receive the latest version of these files.

### Additional information

More information about caching headers can be found in the blog post ["Caching best practices & max-age gotchas" by Jake Archibald](https://jakearchibald.com/2016/caching-best-practices/).

## How to add caching headers for your server

Here are some examples that worked for other users of this template.
See [Issue #70](https://github.com/vuejs-templates/pwa/issues/70) for a discussion.

Apache: Disable all caching for the two essential files

<Files index.html|service-worker.js>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</Files>

Apache: Limit caching to five minutes to all files to prevent unlimited caching also for files in static

Header set Cache-Control "max-age=300, must-revalidate"

Nginx: Limit caching for the two essential files

location ~ (index.html|service-worker.js)$ {
# ...
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
2 changes: 1 addition & 1 deletion meta.js
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ module.exports = {
"short_name": {
"type": "string",
"required": false,
"message": "Project short name: fewer than 12 characters to not be truncated on homescreens (default: same as name)",
"message": "Project short name: fewer than 12 characters to not be truncated on homescreens (default: same as name)"
},
"description": {
"type": "string",
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-cli-template-pwa",
"version": "2.0.1",
"version": "2.1.0",
"license": "MIT",
"description": "A full-featured Webpack setup with hot-reload, lint-on-save, unit testing & css extraction.",
"scripts": {
9 changes: 7 additions & 2 deletions template/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
build/*.js
config/*.js
/build/
/config/
/dist/
/*.js
{{#unit}}
/test/unit/coverage/
{{/unit}}
6 changes: 3 additions & 3 deletions template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.DS_Store
node_modules/
dist/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
{{#unit}}
test/unit/coverage
/test/unit/coverage
{{/unit}}
{{#e2e}}
test/e2e/reports
/test/e2e/reports
selenium-debug.log
{{/e2e}}

18 changes: 10 additions & 8 deletions template/build/build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
'use strict'

require('./check-versions')()

process.env.NODE_ENV = 'production'

var ora = require('ora')
var rm = require('rimraf')
var path = require('path')
var chalk = require('chalk')
var webpack = require('webpack')
var config = require('../config')
var webpackConfig = require('./webpack.prod.conf')
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')

var spinner = ora('building for production...')
const spinner = ora('building for production...')
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
22 changes: 12 additions & 10 deletions template/build/check-versions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
var chalk = require('chalk')
var semver = require('semver')
var packageConfig = require('../package.json')
var shell = require('shelljs')
'use strict'

const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}

var versionRequirements = [
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
@@ -23,9 +25,9 @@ if (shell.which('npm')) {
}

module.exports = function () {
var warnings = []
for (var i = 0; i < versionRequirements.length; i++) {
var mod = versionRequirements[i]
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
@@ -38,8 +40,8 @@ module.exports = function () {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (var i = 0; i < warnings.length; i++) {
var warning = warnings[i]
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
2 changes: 2 additions & 0 deletions template/build/dev-client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

/* eslint-disable */
require('eventsource-polyfill')
var hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
Loading