Skip to content

Commit 958bc51

Browse files
committed
chore: init
0 parents  commit 958bc51

Some content is hidden

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

46 files changed

+11455
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
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 = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
build

.eslintrc.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: ['plugin:vue/vue3-recommended', '@vue/eslint-config-standard'],
7+
parserOptions: {
8+
parser: 'babel-eslint'
9+
},
10+
rules: {
11+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13+
'vue/component-name-in-template-casing': ['error', 'PascalCase'],
14+
'arrow-parens': ['error', 'as-needed'],
15+
'import/order': 0
16+
}
17+
}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
dist
3+
build
4+
5+
.vscode
6+
.idea
7+
.DS_Store

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn commitlint --edit $1

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn lint-staged

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none"
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Anton Reshetov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
<p align="center">
3+
<img src="logo.png" width="150px">
4+
</p>
5+
<h1 align="center">Image Optimizer</h1>
6+
<p align="center">
7+
<strong>Built with Electron, Vue & Vite.</strong>
8+
</p>
9+
10+
A free and open source tool for optimizing images and vector graphics.
11+
12+
<p align="center">
13+
<img src="demo.gif">
14+
</p>
15+
16+
## Core libs
17+
- [mozjpeg](https://github.com/mozilla/mozjpeg)
18+
- [pngquant](https://pngquant.org)
19+
- [SVGO](https://github.com/svg/svgo)
20+
21+
## Download and Installation on macOS
22+
23+
Go to [Releases](https://github.com/antonreshetov/image-optimizer/releases) get the latest build, download and install.
24+
25+
## Development
26+
```bash
27+
# install dependencies
28+
yarn
29+
# serve with hot reload
30+
yarn dev
31+
```
32+
33+
## Build
34+
```bash
35+
# build application for production
36+
yarn build
37+
```
38+
39+
## Related
40+
- [Electron Vue Vite Boilerplate](https://github.com/antonreshetov/electron-vue-vite-boilerplate)
41+
42+
Copyright (c) 2021-present, Anton Reshetov.

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional']
3+
}

config/electron-builder.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const path = require('path')
2+
3+
/**
4+
* https://www.electron.build/configuration/configuration
5+
*/
6+
const config = {
7+
productName: 'Image Optimizer',
8+
appId: 'com.antonreshetov.image-optimizer',
9+
directories: {
10+
output: path.resolve(__dirname, '../dist')
11+
},
12+
nsis: {
13+
oneClick: false,
14+
perMachine: false,
15+
allowToChangeInstallationDirectory: true,
16+
shortcutName: 'Image Optimizer'
17+
},
18+
mac: {
19+
icon: 'build/icons/icon.icns'
20+
},
21+
win: {
22+
target: 'nsis'
23+
},
24+
linux: {
25+
target: ['snap']
26+
},
27+
files: [
28+
'!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}',
29+
'!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}',
30+
'!**/node_modules/*.d.ts',
31+
'!**/node_modules/.bin',
32+
'!src/renderer',
33+
'!config',
34+
'!README.md',
35+
'!scripts',
36+
'!build',
37+
'!dist',
38+
{
39+
from: 'build/renderer',
40+
to: 'renderer',
41+
filter: ['**/*']
42+
}
43+
]
44+
}
45+
46+
module.exports = config

config/vite.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const path = require('path')
2+
const vuePlugin = require('@vitejs/plugin-vue')
3+
const { defineConfig } = require('vite')
4+
5+
/**
6+
* https://vitejs.dev/config
7+
*/
8+
const config = defineConfig({
9+
root: path.resolve(__dirname, '../src/renderer'),
10+
publicDir: 'public',
11+
server: {
12+
port: 8080
13+
},
14+
open: false,
15+
build: {
16+
outDir: path.resolve(__dirname, '../build/renderer'),
17+
emptyOutDir: true
18+
},
19+
plugins: [vuePlugin()],
20+
resolve: {
21+
alias: {
22+
'@': path.resolve(__dirname, '../src/renderer')
23+
}
24+
}
25+
})
26+
27+
module.exports = config

demo.gif

1.16 MB
Loading

jsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"@/*": ["./src/renderer/*"],
6+
"@@/*": ["./src/main/*"]
7+
}
8+
},
9+
"exclude": ["node_modules", ".nuxt", "dist"]
10+
}

logo.png

13.1 KB
Loading

package.json

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"name": "image-optimization",
3+
"version": "1.0.0",
4+
"description": "Electron & Vue 3 application",
5+
"main": "src/main/index.js",
6+
"scripts": {
7+
"dev": "node scripts/dev-server.js",
8+
"build": "node scripts/build.js",
9+
"lint": "npm run prettier && eslint --ext .js,.vue . --fix src",
10+
"prettier": "prettier --write src/**/*.{vue,js}"
11+
},
12+
"repository": "https://github.com/antonreshetov/electron-vue-vite-boilerplate",
13+
"author": {
14+
"name": "Anton Reshetov",
15+
"url": "https://github.com/antonreshetov"
16+
},
17+
"lint-staged": {
18+
"*.{js,vue}": [
19+
"prettier --write",
20+
"eslint --fix",
21+
"git add"
22+
]
23+
},
24+
"devDependencies": {
25+
"@commitlint/cli": "^15.0.0",
26+
"@commitlint/config-conventional": "^15.0.0",
27+
"@vitejs/plugin-vue": "^1.9.3",
28+
"@vue/cli": "^4.5.14",
29+
"@vue/eslint-config-standard": "^6.1.0",
30+
"babel-eslint": "^10.1.0",
31+
"chalk": "^4.1.2",
32+
"chokidar": "^3.5.2",
33+
"electron": "^16.0.1",
34+
"electron-builder": "^22.13.1",
35+
"electron-devtools-installer": "^3.2.0",
36+
"eslint": "^7.0.0",
37+
"eslint-plugin-import": "^2.25.3",
38+
"eslint-plugin-node": "^11.1.0",
39+
"eslint-plugin-promise": "^5.1.1",
40+
"eslint-plugin-standard": "^5.0.0",
41+
"eslint-plugin-vue": "^8.1.1",
42+
"husky": "^6.0.0",
43+
"lint-staged": "^12.0.3",
44+
"prettier": "^2.4.1",
45+
"sass": "^1.43.4",
46+
"vite": "^2.6.10"
47+
},
48+
"dependencies": {
49+
"electron-store": "^8.0.1",
50+
"fs-extra": "^10.0.0",
51+
"junk": "3.1.0",
52+
"mime-types": "^2.1.34",
53+
"mozjpeg": "^7.0.0",
54+
"pngquant-bin": "^6.0.0",
55+
"queue": "^6.0.2",
56+
"svgo": "^2.8.0",
57+
"vue": "^3.0.6"
58+
}
59+
}

scripts/build-electron.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function build () {
2+
const electronBuilder = require('electron-builder')
3+
const config = require('../config/electron-builder')
4+
5+
return electronBuilder.build({
6+
config: config
7+
})
8+
}
9+
10+
module.exports = build

scripts/build-vue.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function build () {
2+
const vite = require('vite')
3+
const viteConfig = require('../config/vite')
4+
5+
return vite.build({
6+
...viteConfig,
7+
base: './',
8+
mode: 'production'
9+
})
10+
}
11+
12+
module.exports = build

scripts/build.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
process.env.NODE_ENV = 'production'
2+
3+
async function build () {
4+
const chalk = require('chalk')
5+
const buildVue = require('./build-vue')
6+
const buildElectron = require('./build-electron')
7+
8+
console.log(`${chalk.blueBright('===============================')}`)
9+
console.log(`${chalk.blueBright('Build started...')}`)
10+
console.log(`${chalk.blueBright('===============================')}`)
11+
12+
await buildVue()
13+
await buildElectron()
14+
15+
console.log(`${chalk.greenBright('===============================')}`)
16+
console.log(`${chalk.greenBright('Build success!')}`)
17+
console.log(`${chalk.greenBright('===============================')}`)
18+
}
19+
20+
build()

scripts/dev-server.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
process.env.NODE_ENV = 'development'
2+
3+
const vite = require('vite')
4+
const { spawn } = require('child_process')
5+
const path = require('path')
6+
const chalk = require('chalk')
7+
const chokidar = require('chokidar')
8+
const electron = require('electron')
9+
10+
let electronProcess = null
11+
let rendererPort = 0
12+
13+
async function startRenderer () {
14+
const config = require('../config/vite.js')
15+
16+
const server = await vite.createServer({
17+
...config,
18+
mode: 'development'
19+
})
20+
21+
return server.listen()
22+
}
23+
24+
function startElectron () {
25+
if (electronProcess) {
26+
return
27+
}
28+
29+
const args = [
30+
path.resolve(__dirname, '../src/main/index.dev.js'),
31+
rendererPort
32+
]
33+
34+
electronProcess = spawn(electron, args)
35+
36+
electronProcess.stdout.on('data', data => {
37+
console.log(chalk.blueBright('[Electron] ') + chalk.white(data.toString()))
38+
})
39+
40+
electronProcess.stderr.on('data', data => {
41+
console.log(chalk.redBright('[Electron] ') + chalk.white(data.toString()))
42+
})
43+
}
44+
45+
function restartElectron () {
46+
if (electronProcess) {
47+
electronProcess.kill()
48+
electronProcess = null
49+
}
50+
51+
startElectron()
52+
}
53+
54+
async function start () {
55+
console.log(`${chalk.blueBright('===============================')}`)
56+
console.log(`${chalk.blueBright('Starting Electron + vite Dev Server...')}`)
57+
console.log(`${chalk.blueBright('===============================')}`)
58+
59+
const devServer = await startRenderer()
60+
rendererPort = devServer.config.server.port
61+
62+
startElectron()
63+
64+
chokidar.watch(path.resolve(__dirname, '../src/main')).on('change', () => {
65+
restartElectron()
66+
})
67+
}
68+
69+
start()

0 commit comments

Comments
 (0)