-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
静态资源的编译路径问题 #117
Comments
如何引入静态资源? |
使用的文档的 import logo from '../../resources/icons/logo.ico?asset';
import logoTemplate from '../../resources/logoTemplate.png?asset'; 配置如下: import { defineConfig } from 'electron-vite';
export default defineConfig(({ mode }) => {
return {
main: {
build: {
outDir: 'dist/main',
lib: {
name: 'mdos',
entry: 'src/main/index.ts',
},
},
},
}) |
脚手架下载的项目做配置也会有这样的问题 import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()],
build: {
outDir: 'dist/main'
}
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {}
}) index.js "use strict";
const electron = require("electron");
const path = require("path");
const utils = require("@electron-toolkit/utils");
const icon = path.join(__dirname, "../../E:/Workspace/VSCodeProjects/electron-vite-app4/resources/icon.png"); |
初始化项目是否正常? |
可重现这个问题,独立修改某个配置 处理方式有两种:
|
通常要确保main、preload和renderer都要输出到一个目录中。各项独立配置时需要确保一级目录是一致的即是这里的 谢谢反馈问题 🤝 |
ok, 感谢解答 |
@fwjyttbtx 提醒一下,因为electron-builder默认构建输出目录是dist,因此将代码输出目录改为dist时,需要修改electron-builder的输出目录(查阅文档),不然会有冲突,会导致打包包裹上一次打包的文件。 |
因为改动了构建的输出目录为release所以才会出现这样的问题 :) |
Describe the bug
outDir被设置后,编译后静态资源的引用地址会变成相对地址加全路径的样式
outDir那怕设置和默认的输出地址
out/main
一致也会出现此现象Electron-Vite Version
1.0.19
Electron Version
23.1.0
Vite Version
4.1.4
Validations
The text was updated successfully, but these errors were encountered: