Skip to content

Commit 551f966

Browse files
authored
Merge pull request #56 from electron-vite/v0.13.14
V0.13.14
2 parents 2f89866 + 4a682f0 commit 551f966

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.13.14 (2023-03-31)
2+
3+
- 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)
4+
15
## 0.13.13 (2023-03-29)
26

37
- 8c044c9 fix: `require` instead `await import`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-plugin-electron-renderer",
3-
"version": "0.13.13",
3+
"version": "0.13.14",
44
"description": "Support use Node.js API in Electron-Renderer",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/cjs-shim.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ export default function cjsShim(): Plugin {
77
return {
88
name: 'vite-plugin-electron-renderer:cjs-shim',
99
apply: 'build',
10+
config(config) {
11+
// Assets are not loaded correctly under CJS, so some default build options need to be changed here
12+
config.build ??= {}
13+
14+
// https://github.com/electron-vite/electron-vite-vue/issues/107
15+
config.build.cssCodeSplit ??= false
16+
17+
// This ensures that static resources are loaded correctly, such as images, `worker.js`
18+
// BWT, the `.js` file can be loaded correctly with `<script id="shim-require-id">`
19+
// This causes BUG in ESN
20+
config.build.assetsDir ??= ''
21+
// TODO: compatible with custom assetsDir for static resources
22+
},
1023
configResolved(_config) {
1124
config = _config
1225

src/index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,6 @@ export default function renderer(options: RendererOptions = {}): VitePlugin {
5252
config.base ??= './'
5353

5454
config.build ??= {}
55-
56-
// https://github.com/electron-vite/electron-vite-vue/issues/107
57-
config.build.cssCodeSplit ??= false
58-
59-
// This ensures that static resources are loaded correctly, such as images, `worker.js`
60-
// BWT, the `.js` file can be loaded correctly with './cjs-shim.ts'
61-
config.build.assetsDir ??= ''
62-
// TODO: compatible with custom assetsDir for static resources
63-
6455
config.build.rollupOptions ??= {}
6556

6657
// Some third-party modules, such as `fs-extra`, it will extend the nativ fs module, maybe we need to stop it

0 commit comments

Comments
 (0)