Comments (4)
这个会在 [email protected] 中解决~
折腾中~
from electron-vite-vue.
这个会在 [email protected] 中解决~
折腾中~
暂时通过 webpack
打包避开打包问题
https://github.com/caoxiemeihao/electron-vue-vite-webpack
from electron-vite-vue.
又是白白折腾的一天~ 😶
虽然犹大说 [email protected] 是真正的 stable 了;2.0 带来的 Dependency Pre-Bunding
带来的 CommonJS and UMD compatibility
确实让人眼前一亮,加上 esbuild
的加入可谓是真滴流皮;可怜我等小白驾驭不了~
配置如下
require('dotenv').config({ path: join(__dirname, '.env') })
import { join } from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
{ // polyfill exports
name: 'custom-template-inject-tag',
transformIndexHtml: (html) => html.replace('<head>', `<head>
<script>const exports = module.exports;</script>`),
},
],
root: join(__dirname, 'src/render'),
base: './', // index.html 中静态资源加载位置
server: {
port: +process.env.PORT,
},
resolve: {
alias: {
'@': join(__dirname, 'src/render'),
'@src': join(__dirname, 'src'),
'@root': __dirname,
},
},
build: {
outDir: join(__dirname, 'dist/render'),
assetsDir: '',
sourcemap: true,
minify: false,
emptyOutDir: true,
rollupOptions: {
output: {
format: 'cjs',
},
external: ['electron'],
},
},
esbuild: {
jsxFactory: 'h',
jsxFragment: 'Fragment',
},
})
两个问题
exports
需要 polyfill 这个不是 vite 的锅,通过插件搞定他- 当引入
electron-store
后编译代码片段如下,俺没辙了 = =
// vendor.ed6bb67c.js
const homedir = path.homedir();
const tmpdir = path.tmpdir();
// ...
const FS = {
chmodAttempt: attemptify.attemptifyAsync(path.promisify(path.chmod), fs_handlers.default.onChangeError),
chownAttempt: attemptify.attemptifyAsync(path.promisify(path.chown), fs_handlers.default.onChangeError),
closeAttempt: attemptify.attemptifyAsync(path.promisify(path.close)),
fsyncAttempt: attemptify.attemptifyAsync(path.promisify(path.fsync)),
mkdirAttempt: attemptify.attemptifyAsync(path.promisify(path.mkdir)),
realpathAttempt: attemptify.attemptifyAsync(path.promisify(path.realpath)),
statAttempt: attemptify.attemptifyAsync(path.promisify(path.stat)),
unlinkAttempt: attemptify.attemptifyAsync(path.promisify(path.unlink)),
closeRetry: retryify.retryifyAsync(path.promisify(path.close), fs_handlers.default.isRetriableError),
fsyncRetry: retryify.retryifyAsync(path.promisify(path.fsync), fs_handlers.default.isRetriableError),
openRetry: retryify.retryifyAsync(path.promisify(path.open), fs_handlers.default.isRetriableError),
readFileRetry: retryify.retryifyAsync(path.promisify(path.readFile), fs_handlers.default.isRetriableError),
renameRetry: retryify.retryifyAsync(path.promisify(path.rename), fs_handlers.default.isRetriableError),
statRetry: retryify.retryifyAsync(path.promisify(path.stat), fs_handlers.default.isRetriableError),
writeRetry: retryify.retryifyAsync(path.promisify(path.write), fs_handlers.default.isRetriableError),
chmodSyncAttempt: attemptify.attemptifySync(path.chmodSync, fs_handlers.default.onChangeError),
chownSyncAttempt: attemptify.attemptifySync(path.chownSync, fs_handlers.default.onChangeError),
closeSyncAttempt: attemptify.attemptifySync(path.closeSync),
mkdirSyncAttempt: attemptify.attemptifySync(path.mkdirSync),
realpathSyncAttempt: attemptify.attemptifySync(path.realpathSync),
statSyncAttempt: attemptify.attemptifySync(path.statSync),
unlinkSyncAttempt: attemptify.attemptifySync(path.unlinkSync),
closeSyncRetry: retryify.retryifySync(path.closeSync, fs_handlers.default.isRetriableError),
fsyncSyncRetry: retryify.retryifySync(path.fsyncSync, fs_handlers.default.isRetriableError),
openSyncRetry: retryify.retryifySync(path.openSync, fs_handlers.default.isRetriableError),
readFileSyncRetry: retryify.retryifySync(path.readFileSync, fs_handlers.default.isRetriableError),
renameSyncRetry: retryify.retryifySync(path.renameSync, fs_handlers.default.isRetriableError),
statSyncRetry: retryify.retryifySync(path.statSync, fs_handlers.default.isRetriableError),
writeSyncRetry: retryify.retryifySync(path.writeSync, fs_handlers.default.isRetriableError)
};
// ...
os、fs两个模块怎么莫名其妙的变成了path 😱
from electron-vite-vue.
import
在打包环境下没问题
require
在开发模式下没问题
基于这个“套路”,写了一个 esm2cjs
的 vite
插件;并且在开发模式下启用
可以试试了!折腾死人了!还是我太菜了!😷
from electron-vite-vue.
Related Issues (20)
- 你好,在这个项目模板中怎么做窗口之间的通信呢? HOT 5
- 打包构建时报错 npm run build:win HOT 10
- 麻烦帮忙看一下。在生产环境启动后,页面空白。在开发环境是没问题的。 HOT 4
- [Help] windows安装包可以支持多语言吗 HOT 2
- 打包electron报x509: certificate has expired or is not yet valid HOT 2
- [Bug] The process not found. When closing app. HOT 1
- [Bug] 升级Electron v29后渲染进程ipcRender报错 HOT 4
- How to pack? HOT 3
- how is work HOT 2
- [Help] mysql2这个npm包无法被排除构建 HOT 4
- [Help] 希望加个eslint。谢谢 HOT 1
- [Bug] 修改renderer代码后,保存,F5可能没生效,关闭程序再次F5就好了
- [Help]如何打开一个新窗口并且使用vue-router跳转 HOT 2
- printWindow.webContents.print({ silent: true })[Help] the title of help wanted report HOT 1
- 有交流群吗或者有官网吗? HOT 1
- [Bug] Missing return statement in invoke method of preload script in Electron template HOT 1
- vite配置了base参数后,build之后找不到js文件 HOT 5
- [Bug] electron降级到22版本提示不支持require() of ES Module HOT 5
- 想要发布用户 客户在线热更新功能 HOT 1
- Can not build success cause of icon set HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-vite-vue.