Skip to content
This repository was archived by the owner on Nov 14, 2022. It is now read-only.

Commit 7ebd639

Browse files
committed
Initial commit
0 parents  commit 7ebd639

34 files changed

+21967
-0
lines changed

.babelrc

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"comments": false,
3+
"env": {
4+
"main": {
5+
"presets": [
6+
["env", {
7+
"targets": {
8+
"node": 7
9+
}
10+
}],
11+
"stage-0"
12+
]
13+
},
14+
"renderer": {
15+
"presets": [
16+
["env", {
17+
"modules": false
18+
}],
19+
"stage-0"
20+
]
21+
},
22+
"web": {
23+
"presets": [
24+
["env", {
25+
"modules": false
26+
}],
27+
"stage-0"
28+
]
29+
}
30+
},
31+
"plugins": ["transform-runtime"]
32+
}

.electron-vue/build.js

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
'use strict'
2+
3+
process.env.NODE_ENV = 'production'
4+
5+
const {
6+
say
7+
} = require('cfonts')
8+
const chalk = require('chalk')
9+
const del = require('del')
10+
const {
11+
spawn
12+
} = require('child_process')
13+
const webpack = require('webpack')
14+
const Multispinner = require('multispinner')
15+
16+
17+
const mainConfig = require('./webpack.main.config')
18+
const rendererConfig = require('./webpack.renderer.config')
19+
const webConfig = require('./webpack.web.config')
20+
21+
const doneLog = chalk.bgGreen.white(' DONE ') + ' '
22+
const errorLog = chalk.bgRed.white(' ERROR ') + ' '
23+
const okayLog = chalk.bgBlue.white(' OKAY ') + ' '
24+
const isCI = process.env.CI || false
25+
26+
if (process.env.BUILD_TARGET === 'clean') clean()
27+
else if (process.env.BUILD_TARGET === 'web') web()
28+
else build()
29+
30+
function clean() {
31+
del.sync(['build/*', '!build/icons', '!build/icons/icon.*'])
32+
console.log(`\n${doneLog}\n`)
33+
process.exit()
34+
}
35+
36+
function build() {
37+
greeting()
38+
39+
del.sync(['dist/electron/*', '!.gitkeep'])
40+
41+
const tasks = ['main', 'renderer']
42+
const m = new Multispinner(tasks, {
43+
preText: 'building',
44+
postText: 'process'
45+
})
46+
47+
let results = ''
48+
49+
m.on('success', () => {
50+
process.stdout.write('\x1B[2J\x1B[0f')
51+
console.log(`\n\n${results}`)
52+
console.log(`${okayLog}take it away ${chalk.yellow('`electron-builder`')}\n`)
53+
process.exit()
54+
})
55+
56+
pack(mainConfig).then(result => {
57+
results += result + '\n\n'
58+
m.success('main')
59+
}).catch(err => {
60+
m.error('main')
61+
console.log(`\n ${errorLog}failed to build main process`)
62+
console.error(`\n${err}\n`)
63+
process.exit(1)
64+
})
65+
66+
pack(rendererConfig).then(result => {
67+
results += result + '\n\n'
68+
m.success('renderer')
69+
}).catch(err => {
70+
m.error('renderer')
71+
console.log(`\n ${errorLog}failed to build renderer process`)
72+
console.error(`\n${err}\n`)
73+
process.exit(1)
74+
})
75+
}
76+
77+
function pack(config) {
78+
return new Promise((resolve, reject) => {
79+
config.mode = 'production'
80+
webpack(config, (err, stats) => {
81+
if (err) reject(err.stack || err)
82+
else if (stats.hasErrors()) {
83+
let err = ''
84+
85+
stats.toString({
86+
chunks: false,
87+
colors: true
88+
})
89+
.split(/\r?\n/)
90+
.forEach(line => {
91+
err += ` ${line}\n`
92+
})
93+
94+
reject(err)
95+
} else {
96+
resolve(stats.toString({
97+
chunks: false,
98+
colors: true
99+
}))
100+
}
101+
})
102+
})
103+
}
104+
105+
function web() {
106+
del.sync(['dist/web/*', '!.gitkeep'])
107+
webConfig.mode = 'production'
108+
webpack(webConfig, (err, stats) => {
109+
if (err || stats.hasErrors()) console.log(err)
110+
111+
console.log(stats.toString({
112+
chunks: false,
113+
colors: true
114+
}))
115+
116+
process.exit()
117+
})
118+
}
119+
120+
function greeting() {
121+
const cols = process.stdout.columns
122+
let text = ''
123+
124+
if (cols > 85) text = 'lets-build'
125+
else if (cols > 60) text = 'lets-|build'
126+
else text = false
127+
128+
if (text && !isCI) {
129+
say(text, {
130+
colors: ['yellow'],
131+
font: 'simple3d',
132+
space: false
133+
})
134+
} else console.log(chalk.yellow.bold('\n lets-build'))
135+
console.log()
136+
}

.electron-vue/dev-client.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const hotClient = require('webpack-hot-middleware/client?noInfo=true&reload=true')
2+
3+
hotClient.subscribe(event => {
4+
/**
5+
* Reload browser when HTMLWebpackPlugin emits a new index.html
6+
*
7+
* Currently disabled until jantimon/html-webpack-plugin#680 is resolved.
8+
* https://github.com/SimulatedGREG/electron-vue/issues/437
9+
* https://github.com/jantimon/html-webpack-plugin/issues/680
10+
*/
11+
// if (event.action === 'reload') {
12+
// window.location.reload()
13+
// }
14+
15+
/**
16+
* Notify `mainWindow` when `main` process is compiling,
17+
* giving notice for an expected reload of the `electron` process
18+
*/
19+
if (event.action === 'compiling') {
20+
document.body.innerHTML += `
21+
<style>
22+
#dev-client {
23+
background: #4fc08d;
24+
border-radius: 4px;
25+
bottom: 20px;
26+
box-shadow: 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
27+
color: #fff;
28+
font-family: 'Source Sans Pro', sans-serif;
29+
left: 20px;
30+
padding: 8px 12px;
31+
position: absolute;
32+
}
33+
</style>
34+
35+
<div id="dev-client">
36+
Compiling Main Process...
37+
</div>
38+
`
39+
}
40+
})

0 commit comments

Comments
 (0)