diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f218ab..84b622b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.13.14 (2023-03-31) + +- c68d26a fix: move cjs config to cjs-shim.ts #107 | [electron-vite-vue/issues/107](https://github.com/electron-vite/electron-vite-vue/issues/107) + ## 0.13.13 (2023-03-29) - 8c044c9 fix: `require` instead `await import` diff --git a/package.json b/package.json index c860bf2..f06b27a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-electron-renderer", - "version": "0.13.13", + "version": "0.13.14", "description": "Support use Node.js API in Electron-Renderer", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/cjs-shim.ts b/src/cjs-shim.ts index 47f9fa4..1c37c2c 100644 --- a/src/cjs-shim.ts +++ b/src/cjs-shim.ts @@ -7,6 +7,19 @@ export default function cjsShim(): Plugin { return { name: 'vite-plugin-electron-renderer:cjs-shim', apply: 'build', + config(config) { + // Assets are not loaded correctly under CJS, so some default build options need to be changed here + config.build ??= {} + + // https://github.com/electron-vite/electron-vite-vue/issues/107 + config.build.cssCodeSplit ??= false + + // This ensures that static resources are loaded correctly, such as images, `worker.js` + // BWT, the `.js` file can be loaded correctly with `