Skip to content

Commit bdc3c56

Browse files
committed
Create new documentation website
1 parent 0d70453 commit bdc3c56

19 files changed

+453
-197
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ typings/
5858
.env
5959

6060
# Vue Cli test projects
61-
/__tests__/projects
61+
/__tests__/projects
62+
63+
# VuePress dist
64+
/docs/.vuepress/dist

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
docs/
2+
.github/
3+
__mocks__/
4+
__tests__/

README.md

Lines changed: 2 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ AppVeyor build status: [![Build status](https://ci.appveyor.com/api/projects/sta
66

77
**IMPORTANT: Your app must be created with Vue-CLI 3 (vue create my-app), will not work with Vue-CLI 2 (vue init webpack my-app)!**
88

9-
**IMPORTANT: If you were previously using an older version of vue-cli-plugin-electron-builder (<1.0.0), please see the [upgrade guide](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/UPGRADING.md).**
9+
**IMPORTANT: These docs are for the v1.0.0-beta release of VCP Electron Builder. If you were previously using an older version of vue-cli-plugin-electron-builder (<1.0.0), please see the [upgrade guide](https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/upgrading.html) or [view the old docs](https://github.com/nklayman/vue-cli-plugin-electron-builder/tree/legacy).**
1010

1111
## Quick Start:
1212

@@ -38,168 +38,4 @@ or with NPM:
3838

3939
`npm run build:electron`
4040

41-
### Folder Structure:
42-
43-
```
44-
├── dist_electron/
45-
│ ├── bundled/.. # where webpack outputs compiled files
46-
│ ├── [target platform]-unpacked/.. # unpacked Electron app (main app and supporting files)
47-
│ ├── [application name] setup [version].[target binary (exe|dmg|rpm...)] # installer for Electron app
48-
│ ├── background.js # compiled background file used for serve:electron
49-
│ └── ...
50-
├── public/ # Files placed here will be avalible through __static or process.env.BASE_URL
51-
├── src/
52-
│ ├── background.[js|ts] # electron entry file (for Electron's main process)
53-
│ ├── [main|index].[js|ts] # your app's entry file (for Electron's render process)
54-
│ └── ...
55-
├── package.json # your app's package.json file
56-
├── ...
57-
```
58-
59-
### Is this plugin production ready?
60-
61-
This plugin is nearly production ready. It has test coverage for everything but the ui interface and proper logging of errors. It needs to be used a little bit more in large applications before it is considered safe to use in a large production environment. Please try it in your app and report any bugs or feature requests.
62-
63-
## Configuration:
64-
65-
### Configuring Electron Builder:
66-
67-
To see available options, check out [Electron Builder Configuration Options](https://www.electron.build/configuration/configuration)
68-
69-
They can be placed under the `builderOptions` key in vue-cli-plugin-electron-builder's plugin options in `vue.config.js`
70-
71-
```javascript
72-
// vue.config.js
73-
74-
module.exports = {
75-
pluginOptions: {
76-
electronBuilder: {
77-
builderOptions: {
78-
// options placed here will be merged with default configuration and passed to electron-builder
79-
}
80-
}
81-
}
82-
}
83-
```
84-
85-
### Webpack configuration:
86-
87-
Your regular config is used for bundling the renderer process (your app). To modify the webpack config for the electron main process only, use the `chainWebpackMainProcess` function under vue-cli-plugin-electron-builder's plugin options in `vue.config.js`. To learn more about webpack chaining, see [webpack-chain](https://github.com/mozilla-neutrino/webpack-chain). The function should take a config argument, modify it through webpack-chain, and then return it.
88-
89-
**Note: Do NOT change the webpack output directory for the main process! See changing output directory below for more info. To change the entry point for the main process, use the `mainProcessFile` key, DO NOT modify it in through chaining.**
90-
91-
```javascript
92-
// vue.config.js
93-
94-
module.exports = {
95-
configureWebpack: {
96-
// Configuration applied to all builds
97-
},
98-
pluginOptions: {
99-
electronBuilder: {
100-
chainWebpackMainProcess: config => {
101-
// Chain webpack config for electron main process only
102-
},
103-
mainProcessFile: 'src/myBackgroundFile.js'
104-
}
105-
}
106-
}
107-
```
108-
109-
### Handling static assets:
110-
111-
#### Renderer process (main app):
112-
113-
In the renderer process, static assets work similarly to a regular app. Read Vue CLI's documentation [here](https://cli.vuejs.org/guide/html-and-static-assets.html) before continuing. However, there are a few changes made:
114-
115-
- The `__static` global variable is added. It provides a path to your public directory in both development and production. Use this to read/write files in your app's public directory.
116-
- In production, the `process.env.BASE_URL` is replaced with the path to your app's files.
117-
118-
**Note: `__static` is not available in regular build/serve. It should only be used in electron to read/write files on disk. To import a file (img, script, etc...) and not have it be transpiled by webpack, use the `process.env.BASE_URL` instead.**
119-
120-
#### Main process (background.js):
121-
122-
The main process won't have access to `process.env.BASE_URL` or `src/assets`. However, you can still use `__static` to get a path to your public directory in development and production.
123-
124-
#### Examples:
125-
126-
```html
127-
<!-- Renderer process only -->
128-
<!-- This image will be processed by webpack and placed under img/ -->
129-
<img src="./assets/logo.png">
130-
<!-- Renderer process only -->
131-
<!-- This image will no be processed by webpack, just copied-->
132-
<!-- imgPath should equal `path.join(process.env.BASE_URL, 'logo.png')` -->
133-
<img :src="imgPath">
134-
<!-- Both renderer and main process -->
135-
<!-- This will read the contents of public/myText.txt -->
136-
<script>
137-
const fs = require('fs')
138-
const path = require('path')
139-
140-
// Expects myText.txt to be placed in public folder
141-
const fileLocation = path.join(__static, 'myText.txt')
142-
const fileContents = fs.readFileSync(fileLocation, 'utf8')
143-
144-
console.log(fileContents)
145-
</script>
146-
```
147-
148-
### Changing the output directory:
149-
150-
If you don't want your files outputted into dist_electron, you can choose a custom folder in vue-cli-plugin-electron-builder's plugin options.
151-
**Note: after changing this, you MUST update the main field of your `package.json` to `[new dir]/bundled/background.js`. It is also recommended to add the new directory to your .gitignore file.**
152-
153-
```javascript
154-
// vue.config.js
155-
156-
module.exports = {
157-
pluginOptions: {
158-
electronBuilder: {
159-
outputDir: 'electron-builder-output-dir'
160-
}
161-
}
162-
}
163-
```
164-
165-
### Cli Options:
166-
167-
Arguments passed to `build:electron` are sent to electron-builder. To see available cli options, see [electron-builder's cli options](https://www.electron.build/cli). `serve:electron` takes no arguments.
168-
169-
### TypeScript Support:
170-
171-
Typescript support is automatic and requires no configuration, just add the `@vue/typescript` cli plugin. There are a few options for configuring typescript if necessary:
172-
173-
```javascript
174-
// vue.config.js
175-
176-
module.exports = {
177-
pluginOptions: {
178-
electronBuilder: {
179-
// option: default // description
180-
disableMainProcessTypescript: false, // Manually disable typescript plugin for main process. Enable if you want to use regular js for the main process (src/background.js by default).
181-
mainProcessTypeChecking: false // Manually enable type checking during webpck bundling for background file.
182-
}
183-
}
184-
}
185-
```
186-
187-
If you are adding typescript after vue-cli-plugin-electron-builder, you may also want to set `mainWindow`'s type to `any` and change `process.env.WEBPACK_DEV_SERVER_URL` to `process.env.WEBPACK_DEV_SERVER_URL as string` to fix type errors. If you add typescript first, this will be done automatically.
188-
189-
## How it works:
190-
191-
### Build command:
192-
193-
The build command consists of three main phases: render build, main build, and electron-builder build:
194-
195-
1. Render build: This phase calls `vue-cli-service build` with some custom configuration so it works properly with electron. (The render process is your standard app.)
196-
2. Main build: This phase is where vue-cli-plugin-electron-builder bundles your background file for the main process (`src/background.js`).
197-
3. Electron-builder build: This phase uses [electron-builder](https://www.electron.build) to turn your web app code into an desktop app powered by [Electron](https://electronjs.org).
198-
199-
### Serve command:
200-
201-
The serve command also consists of 3 main phases: main build, dev server launch, and electron launch:
202-
203-
1. Dev server launch: This phase starts the built in dev server with a few modifications to work properly with electron.
204-
2. Main build: This phase, like in the build command, bundles your app's main process, but in development mode.
205-
3. Electron launch: This phase launches electron and tells it to load the url of the above dev server.
41+
To see more documentation, [visit our website](https://nklayman.github.io/vue-cli-plugin-electron-builder/).

UPGRADING.md

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
# Upgrading
2-
3-
**Note: This guide is for upgrading from <=v0.3.2 to >=v1.0.0.**
4-
5-
## Steps:
6-
7-
1. Re-invoke the generator for vue-cli-plugin-electron-builder by running `vue invoke electron-builder`. Make sure to update the package before running.
8-
2. You may delete `src/main/index.js`. If you have modified it, those modifications must be moved to `src/background.js` after re-invoking the generator.
9-
3. You may delete any electron-webpack config options, they will not be used. By default, they are in `package.json` under `electronWebpack`.
10-
4. You may delete any electron-builderconfig options, they will not be used. By default, they are in `package.json` under `build`. Any changes that you have made to these must be [moved to plugin options](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#configuring-electron-builder).
11-
5. You may remove `webpackConfig` and `webpackMainConfig` from vue-cli-plugin-electron-builder's plugin options. Webpack config for the renderer process is your normal webpack config, and you can use the `chainWebpackMainProcess` function ([guide](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#webpack-configuration)).
12-
6. You may remove `electron-webpack`, `electron-builder`, and, if used, `electron-webpack-ts` from your devDependencies. You may also remove `source-map-support` from your dependencies.
13-
14-
## What has changed:
15-
16-
- Electron-webpack is no longer used. Instead, your app is built as normal (but with some slight configuration changes).
17-
- This means there is no need to change your config to work with stylus, sass, or any other special files.
18-
- Typescript support is [automatic](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#adding-typescript-support) for both processes, just add the `@vue/typescript` plugin.
19-
- Your normal build will not be overwritten by `build:electron`.
20-
- The [folder structure](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#folder-structure) has changed dramatically.
21-
- Electron-builder's [config](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#configuring-electron-builder) is now taken from the `builderConfig` key in vue-cli-plugin-electron-builder's plugin options.
22-
- To learn more about the internals of this plugin, see [how it works](https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v1-dev/README.md#how-it-works).
1+
The upgrade guide has moved to [our website](https://nklayman.github.io/vue-cli-plugin-electron-builder/guide/upgrading.html).

deployDocs.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const execa = require('execa')
2+
const deploy = () =>
3+
new Promise(async resolve => {
4+
// Build docs
5+
await execa('yarn', ['docs:build'], {
6+
stdio: 'inherit'
7+
})
8+
9+
// Push to github
10+
await execa('git', ['init'], {
11+
stdio: 'inherit',
12+
cwd: './docs/.vuepress/dist'
13+
})
14+
await execa('git', ['add', '-A'], {
15+
stdio: 'inherit',
16+
cwd: './docs/.vuepress/dist'
17+
})
18+
await execa('git', ['commit', '-m', 'deploy'], {
19+
stdio: 'inherit',
20+
cwd: './docs/.vuepress/dist'
21+
})
22+
await execa(
23+
'git',
24+
[
25+
'push',
26+
'-f',
27+
'https://github.com/nklayman/vue-cli-plugin-electron-builder.git',
28+
'master:gh-pages'
29+
],
30+
{
31+
cwd: './docs/.vuepress/dist'
32+
}
33+
)
34+
resolve()
35+
})
36+
deploy().then(() => {
37+
console.log('Deploy Complete')
38+
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div style="text-align:center">
3+
<slot></slot>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: 'centeredMarkdown'
10+
}
11+
</script>

docs/.vuepress/config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
title: 'VCP Electron Builder',
3+
description:
4+
'A Vue CLI 3 plugin for Electron with no required configuration.',
5+
base: '/vue-cli-plugin-electron-builder/',
6+
head: [['link', { rel: 'shortcut icon', href: '/favicon.ico' }]],
7+
themeConfig: {
8+
nav: [{ text: 'Home', link: '/' }, { text: 'Guide', link: '/guide/' }],
9+
sidebar: {
10+
'/guide/': [
11+
'',
12+
'guide',
13+
'configuration',
14+
'testingAndDebugging',
15+
'upgrading'
16+
]
17+
},
18+
displayAllHeaders: true,
19+
repo: 'nklayman/vue-cli-plugin-electron-builder',
20+
docsDir: 'docs',
21+
editLinks: true,
22+
editLinkText: 'Is something wrong or missing? Edit this page on github!'
23+
}
24+
}

docs/.vuepress/public/favicon.ico

31.6 KB
Binary file not shown.

docs/.vuepress/public/hero.png

139 KB
Loading

docs/.vuepress/public/logo.png

35.1 KB
Loading

0 commit comments

Comments
 (0)