better resolveElectron comment
This commit is contained in:
		
							parent
							
								
									3d41a6baad
								
							
						
					
					
						commit
						38f0a11824
					
				| 
						 | 
					@ -11,7 +11,16 @@ export default defineConfig({
 | 
				
			||||||
  root: join(__dirname, '../src/renderer'),
 | 
					  root: join(__dirname, '../src/renderer'),
 | 
				
			||||||
  plugins: [
 | 
					  plugins: [
 | 
				
			||||||
    react(),
 | 
					    react(),
 | 
				
			||||||
    resolveElectron(),
 | 
					    resolveElectron(
 | 
				
			||||||
 | 
					      /**
 | 
				
			||||||
 | 
					       * you can custom other module in here
 | 
				
			||||||
 | 
					       * 🚧 need to make sure custom-resolve-module in `dependencies`, that will ensure that the electron-builder can package them correctly
 | 
				
			||||||
 | 
					       * @example
 | 
				
			||||||
 | 
					       * {
 | 
				
			||||||
 | 
					       *   'electron-store': 'const Store = require("electron-store"); export defalut Store;',
 | 
				
			||||||
 | 
					       * }
 | 
				
			||||||
 | 
					       */
 | 
				
			||||||
 | 
					    ),
 | 
				
			||||||
  ],
 | 
					  ],
 | 
				
			||||||
  base: './',
 | 
					  base: './',
 | 
				
			||||||
  build: {
 | 
					  build: {
 | 
				
			||||||
| 
						 | 
					@ -32,7 +41,7 @@ export default defineConfig({
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ------- For use Electron, NodeJs in Renderer-process -------
 | 
					// ------- For use Electron, NodeJs in Renderer-process -------
 | 
				
			||||||
// https://github.com/caoxiemeihao/electron-vue-vite/issues/52
 | 
					// https://github.com/caoxiemeihao/electron-vue-vite/issues/52
 | 
				
			||||||
export function resolveElectron(): Plugin[] {
 | 
					export function resolveElectron(dict: Parameters<typeof resolve>[0] = {}): Plugin[] {
 | 
				
			||||||
  const builtins = builtinModules.filter(t => !t.startsWith('_'))
 | 
					  const builtins = builtinModules.filter(t => !t.startsWith('_'))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return [
 | 
					  return [
 | 
				
			||||||
| 
						 | 
					@ -49,8 +58,7 @@ export function resolveElectron(): Plugin[] {
 | 
				
			||||||
    resolve({
 | 
					    resolve({
 | 
				
			||||||
      electron: electronExport(),
 | 
					      electron: electronExport(),
 | 
				
			||||||
      ...builtinModulesExport(builtins),
 | 
					      ...builtinModulesExport(builtins),
 | 
				
			||||||
      // you can custom other module in here, need to make sure it's in `dependencies`
 | 
					      ...dict,
 | 
				
			||||||
      // 'electron-store': 'const Store = require("electron-store"); export defalut Store;'
 | 
					 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  ]
 | 
					  ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue