Skip to content

Commit d36c22c

Browse files
committed
Add new source files
1 parent 81ab887 commit d36c22c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+12015
-820
lines changed

.babelrc

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

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 4
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.electron-vue/build.js

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

.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)