Skip to content

Commit b492388

Browse files
authored
Create release 1.1.6 (#37)
* Fix to nginx statement (#22) Missing end statement ; Correction of $url -> $uri * Update tag to reflect 1.1.4 release * Fix typo in README * Bump version in README badge * Provide workaround for global installs in Puppeteer image The NPM prefix needs to be set somewhere with write access for global packages, which the image doesn't set for the default prefix. * Added information about customRendererConfig (#26) * Fixes error if there's no pluginOptions.prerenderSpa in vue.config.js (#35) * Bump lodash from 4.17.10 to 4.17.15 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.10 to 4.17.15. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](lodash/lodash@4.17.10...4.17.15) Signed-off-by: dependabot[bot] <support@github.com> * Bump version
1 parent 3a7a915 commit b492388

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Add `prerender-spa-plugin` into your Vue application with zero configuration.
55
![](https://img.shields.io/david/solarliner/vue-cli-plugin-prerender-spa.svg)
66
![](https://img.shields.io/david/dev/solarliner/vue-cli-plugin-prerender-spa.svg)
77
![](https://img.shields.io/npm/v/vue-cli-plugin-prerender-spa.svg)
8-
![](https://img.shields.io/github/commits-since/solarliner/vue-cli-plugin-prerender-spa/1.1.3.svg)
8+
![](https://img.shields.io/github/commits-since/solarliner/vue-cli-plugin-prerender-spa/1.1.6.svg)
99

1010
**Looking for a co-maintainer**: I'm continuing to maintain this project, hoever
1111
I still would like help on some of the issues, and generally to help me keep this
@@ -134,6 +134,35 @@ root directory of the project; where you can specify custom options for the
134134
Puppeteer renderer. It will be merged, and its options will overwrite those set
135135
by the plugin itself.
136136

137+
Other way to set custom configuration for the Puppeteer renderer is to use `customRendererConfig`
138+
dictionary of possible [Puppeteer launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).
139+
140+
Example configuration of debugging your site with Chrome DevTools opened automatically:
141+
142+
```js
143+
// vue.config.js
144+
145+
module.exports = {
146+
pluginOptions: {
147+
prerenderSpa: {
148+
registry: undefined,
149+
renderRoutes: [
150+
'/',
151+
'/about'
152+
],
153+
useRenderEvent: true,
154+
onlyProduction: true,
155+
156+
headless: false, // <- this could also be inside the customRendererConfig
157+
customRendererConfig:
158+
{
159+
args: ["--auto-open-devtools-for-tabs"]
160+
}
161+
}
162+
}
163+
}
164+
```
165+
137166
### User post processing function
138167

139168
Pupeteer allows to postprocess the HTML after it's been snapshot, and the plugin
@@ -142,7 +171,7 @@ allows you to provide your own function if you need to.
142171
Add a `postProcess` option into your `vue.config.js` file to provide a custom
143172
post-processing function to run on every build.
144173

145-
Exemple configuration:
174+
Example configuration:
146175

147176
```js
148177
// vue.config.js
@@ -197,7 +226,7 @@ Here's an example nginx configuration snippet:
197226

198227
```nginx
199228
location / {
200-
try_files $url $url/index.html $url.html /app.html
229+
try_files $uri $uri/index.html $uri.html /app.html;
201230
}
202231
```
203232

@@ -225,6 +254,14 @@ job itself - rather, it is recommended to switch to a Node.js + Puppeteer
225254
image where you can just use your `install && build` workflow without any
226255
additional configuration. I personally use the `alekzonder/puppeteer` image.
227256

257+
If you do decide on using alekzonder/puppeteer and you want to install global npm packages. The following commands can be used prior to the installation of your required global package to ensure that you do not receive an `EACCES: permission denied, access '/usr/local/lib/node_modules'` error. I have tested this using Gitlab CI.
258+
259+
```
260+
- mkdir ~/.npm-global
261+
- npm config set prefix '~/.npm-global'
262+
- npm install -g @vue/cli-service-global
263+
```
264+
228265
### Compatibility with other Vue CLI plugins
229266

230267
This plugin should be compatible with any plugin that doesn't add a `mounted()`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-cli-plugin-prerender-spa",
3-
"version": "1.1.5",
3+
"version": "1.1.6",
44
"description": "Vue CLI plugin to add prerendering to your application",
55
"main": "index.js",
66
"author": {

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function entry(api, projectOptions) {
1717
function chain(api, projectOptions) {
1818
return config => {
1919
const options = createPluginOptions(api, projectOptions);
20+
if(!options || options.disable) return // If there aren't any options or disabled, don't run
2021
if (options.onlyProduction && process.env.NODE_ENV !== "production") {
2122
return;
2223
}
@@ -95,7 +96,7 @@ function createRendererConfig(api, projectOptions) {
9596
}
9697

9798
function createPluginOptions(api, projectOptions) {
98-
let options;
99+
let options = {}; // Fixes Object.assign error if there's no 'pluginOptions.prerenderSpa' in vue.config.js
99100
let oldConfigPath = api.resolve(".prerender-spa.json");
100101
try {
101102
options = pickle(projectOptions, CONFIG_OBJ_PATH);
@@ -107,6 +108,7 @@ function createPluginOptions(api, projectOptions) {
107108
options = JSON.parse(readFileSync(oldConfigPath).toString("utf-8"));
108109
}
109110
}
111+
if(Object.entries(options).length === 0) return undefined // No options at all, therefore don't return any options.
110112
// return options; // TODO: Fix #16 permanently
111113
return Object.assign(options, { onlyProduction: true }); // Force disable on development build, workaround for #16
112114
}

yarn.lock

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,14 +1595,10 @@ lodash.debounce@^4.0.8:
15951595
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
15961596
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=
15971597

1598-
lodash@^4.17.10:
1599-
version "4.17.11"
1600-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
1601-
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
1602-
1603-
lodash@^4.17.5:
1604-
version "4.17.10"
1605-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
1598+
lodash@^4.17.10, lodash@^4.17.5:
1599+
version "4.17.15"
1600+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
1601+
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
16061602

16071603
loose-envify@^1.0.0:
16081604
version "1.4.0"

0 commit comments

Comments
 (0)