Skip to content

Commit

Permalink
Merge pull request #56 from electron-vite/v0.13.14
Browse files Browse the repository at this point in the history
V0.13.14
  • Loading branch information
caoxiemeihao authored Mar 31, 2023
2 parents 2f89866 + 4a682f0 commit 551f966
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/cjs-shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<script id="shim-require-id">`
// This causes BUG in ESN
config.build.assetsDir ??= ''
// TODO: compatible with custom assetsDir for static resources
},
configResolved(_config) {
config = _config

Expand Down
9 changes: 0 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,6 @@ export default function renderer(options: RendererOptions = {}): VitePlugin {
config.base ??= './'

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 './cjs-shim.ts'
config.build.assetsDir ??= ''
// TODO: compatible with custom assetsDir for static resources

config.build.rollupOptions ??= {}

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

0 comments on commit 551f966

Please sign in to comment.