iT邦幫忙

0

vite 和 electron.js 的打包問題?

QQ 2023-04-19 12:45:49657 瀏覽
  • 分享至 

  • xImage

因為 Electron 可以直接使用 node.js api
所以我在 index.js require 一個自訂的模組

開發狀態下 localhost 的目錄沒有 test.js 這個檔案

打包時要如何讓 vite 自動檢查到我 require 的這個模組並打包?

vite 如何處理此類型的問題?

目錄結構

index.html
/src/index.js
/src/test.js
/js/app.jsx
/js/main.jsx

index.html

<script src="src/index.js"></script>
<script type="module" src="/src/js/main.jsx"></script>

index.js

const test = require("./test");
console.log("index.js");
test();

test.js

const process = require("process");
const test = () => {
  console.log(process.cwd());
};
module.exports = test;
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答