-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from electron-vite/v0.9.0
V0.9.0
- Loading branch information
Showing
14 changed files
with
230 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,4 +109,5 @@ package-lock.json | |
# pnpm-lock.yaml | ||
yarn.lock | ||
|
||
release | ||
packages/electron-renderer/plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## 0.9.0 (2022-08-12) | ||
|
||
🎉 `v0.9.0` is a stable version based on `[email protected]` | ||
|
||
#### vite-plugin-electron | ||
|
||
#### vite-plugin-electron-renderer | ||
|
||
- ebc6a3d chore(electron-renderer): remove `renderBuiltUrl()` based on [email protected] ([[email protected]](https://github.com/vitejs/vite/pull/9381/commits/8f2065efcb6ba664f7dce6f3c7666b29e2c56027#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7L874)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import path from 'path' | ||
import type { Plugin } from 'vite' | ||
|
||
// https://github.com/vitejs/vite/blob/main/packages/vite/src/node/constants.ts#L84-L124 | ||
const KNOWN_ASSET_TYPES = [ | ||
// images | ||
'png', | ||
'jpe?g', | ||
'jfif', | ||
'pjpeg', | ||
'pjp', | ||
'gif', | ||
'svg', | ||
'ico', | ||
'webp', | ||
'avif', | ||
|
||
// media | ||
'mp4', | ||
'webm', | ||
'ogg', | ||
'mp3', | ||
'wav', | ||
'flac', | ||
'aac', | ||
|
||
// fonts | ||
'woff2?', | ||
'eot', | ||
'ttf', | ||
'otf', | ||
|
||
// other | ||
'webmanifest', | ||
'pdf', | ||
'txt' | ||
] | ||
|
||
export default function buildConfig(): Plugin { | ||
return { | ||
name: 'vite-plugin-electron-renderer:build-config', | ||
apply: 'build', | ||
config(config) { | ||
// make sure that Electron can be loaded into the local file using `loadFile` after packaging | ||
if (config.base === undefined) config.base = './' | ||
|
||
if (config.build === undefined) config.build = {} | ||
|
||
// TODO: init `config.build.target` | ||
// https://github.com/vitejs/vite/pull/8843 | ||
|
||
// ensure that static resources are loaded normally | ||
// TODO: Automatic splicing `build.assetsDir` | ||
if (config.build.assetsDir === undefined) config.build.assetsDir = '' | ||
|
||
// https://github.com/electron-vite/electron-vite-vue/issues/107 | ||
if (config.build.cssCodeSplit === undefined) config.build.cssCodeSplit = false | ||
|
||
// prevent accidental clearing of `dist/electron/main`, `dist/electron/preload` | ||
if (config.build.emptyOutDir === undefined) config.build.emptyOutDir = false | ||
|
||
// `Uncaught TypeError: Failed to construct 'URL': Invalid URL` #44 | ||
// `[email protected]` fixed this BUG 🐞 | ||
// https://github.com/vitejs/vite/pull/9381/commits/8f2065efcb6ba664f7dce6f3c7666b29e2c56027#diff-aa53520bfd53e6c24220c44494457cc66370fd2bee513c15f9be7eb537a363e7L874 | ||
if (!config.experimental) config.experimental = { | ||
renderBuiltUrl(filename, type) { | ||
if ( | ||
KNOWN_ASSET_TYPES.includes(path.extname(filename).slice(1)) && | ||
type.hostType === 'js' | ||
) { | ||
// Avoid Vite relative-path assets handling | ||
// https://github.com/vitejs/vite/blob/89dd31cfe228caee358f4032b31fdf943599c842/packages/vite/src/node/build.ts#L850-L862 | ||
return { runtime: JSON.stringify(filename) } | ||
} | ||
// TODO: replace `config.build.assetsDir` for chunk js | ||
// TODO: replace `config.build.assetsDir` for split css | ||
}, | ||
} | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @see https://www.electron.build/configuration/configuration | ||
*/ | ||
{ | ||
appId: "YourAppID", | ||
productName: "YourAppName", | ||
copyright: "Copyright © 2022 ${author}", | ||
asar: false, | ||
directories: { | ||
output: "release/${version}", | ||
buildResources: "electron/resources", | ||
}, | ||
files: ["dist"], | ||
win: { | ||
target: [ | ||
{ | ||
target: "nsis", | ||
arch: ["x64"], | ||
}, | ||
], | ||
artifactName: "${productName}-Windows-${version}-Setup.${ext}", | ||
}, | ||
nsis: { | ||
oneClick: false, | ||
perMachine: false, | ||
allowToChangeInstallationDirectory: true, | ||
deleteAppDataOnUninstall: false, | ||
}, | ||
mac: { | ||
target: ["dmg"], | ||
artifactName: "${productName}-Mac-${version}-Installer.${ext}", | ||
}, | ||
linux: { | ||
target: ["AppImage"], | ||
artifactName: "${productName}-Linux-${version}.${ext}", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
"main": "dist/electron/main/index.js", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vue-tsc --noEmit && vite build && electron-builder" | ||
"build": "vite build && electron-builder" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"author": "草鞋没号 <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"serialport": "^10.4.0", | ||
|
@@ -24,6 +24,6 @@ | |
"node-fetch": "^3.2.8", | ||
"vite-plugin-electron": "workspace:*", | ||
"vite-plugin-esmodule": "^1.4.1", | ||
"vite": "^3.0.2" | ||
"vite": "^3.0.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* @see https://www.electron.build/configuration/configuration | ||
*/ | ||
{ | ||
appId: "YourAppID", | ||
productName: "YourAppName", | ||
copyright: "Copyright © 2022 ${author}", | ||
asar: false, | ||
directories: { | ||
output: "release/${version}", | ||
buildResources: "electron/resources", | ||
}, | ||
files: ["dist"], | ||
win: { | ||
target: [ | ||
{ | ||
target: "nsis", | ||
arch: ["x64"], | ||
}, | ||
], | ||
artifactName: "${productName}-Windows-${version}-Setup.${ext}", | ||
}, | ||
nsis: { | ||
oneClick: false, | ||
perMachine: false, | ||
allowToChangeInstallationDirectory: true, | ||
deleteAppDataOnUninstall: false, | ||
}, | ||
mac: { | ||
target: ["dmg"], | ||
artifactName: "${productName}-Mac-${version}-Installer.${ext}", | ||
}, | ||
linux: { | ||
target: ["AppImage"], | ||
artifactName: "${productName}-Linux-${version}.${ext}", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
"main": "dist/electron/main.js", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vue-tsc --noEmit && vite build && electron-builder" | ||
"build": "vite build && electron-builder" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"author": "草鞋没号 <[email protected]>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"serialport": "^10.4.0", | ||
|
@@ -24,6 +24,6 @@ | |
"node-fetch": "^3.2.8", | ||
"vite-plugin-electron": "workspace:*", | ||
"vite-plugin-esmodule": "^1.4.1", | ||
"vite": "^3.0.2" | ||
"vite": "^3.0.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.