Giter VIP home page Giter VIP logo

electron-vue-vite's Introduction

electron-vue-vite

Electron + vue3 + vite2 + ant-design-vue2 整合

🐛 已知问题

How and Why

  • 写这个 Demo 项目主要有两个目的
    1. [email protected] 发布了,想试试新功能
    2. 工作中用的 umi+electron 项目大了,启动速度并不理想; 用 vite 试试,算一个储备方案 ^_^

Command

  • npm run dev
  • npm run build


Note 踩坑记

  • import { write } from 'fs' 的这种形式会被 vite 编译成 /@modules/fs?import
  • const { write } = require('fs') 这种形式就能用了 😉
  • const { ipcRenderer } = require('electron') 同理
  • 21-02-18 "rollup-plugin-esbuild": "^2.4.2", 有 BUG
  • 21-02-18 tsconfig.json中不能有多余的逗号,不然 rollup-plugin-esbuild 会有如下警告
     SyntaxError: Unexpected token ] in JSON at position 428
        at JSON.parse (<anonymous>)
        at Object.load (/Users/caoxie/Desktop/github/electron-vue-vite2/node_modules/rollup-plugin-esbuild/dist/index.js:21:17) {
      code: 'PLUGIN_ERROR',
      plugin: 'esbuild',
      hook: 'transform',
      id: '/Users/caoxie/Desktop/github/electron-vue-vite2/src/main/index.ts',
      watchFiles: [
        '/Users/caoxie/Desktop/github/electron-vue-vite2/src/main/index.ts'
      ]
    }
  • 21-02-18 main 进程中暂时无法用 require,打包后会导致模块找不到
  • 21-02-18 "asar": false 这样可以保障 "extraResources" 能够正常搬运到文件夹中
  • 21-02-18 报错 React is not defined
    • 参考链接 https://github.com/vitejs/vite/issues/1286
    • 参考链接 https://github.com/vitejs/vite/tree/main/packages/plugin-vue-jsx
    // vite.config.js
    import vueJsx from '@vitejs/plugin-vue-jsx'
    
    export default {
      plugins: [
        vueJsx({
          // options are passed on to @vue/babel-plugin-jsx
        })
      ],
      esbuild: {
        jsxFactory: 'h',
        jsxFragment: 'Fragment'
      },
    }
  • 21-02-19 报错 https://github.com/ajv-validator/ajv/issues/1399
    Circular dependency: node_modules\conf\node_modules\ajv\dist\compile\validate\dataType.js -> node_modules\conf\node_modules\ajv\dist\compile\util.js -> node_modules\conf\node_modules\ajv\dist\compile\validate\index.js -> node_modules\conf\node_modules\ajv\dist\compile\validate\dataType.js

License

MIT License

electron-vue-vite's People

Contributors

caoxiemeihao avatar zywj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.