fix(web): editor.html CSS 改 import 进 bundle,修生产构建 404
editor.html 三条 /node_modules/*.css 绝对 link 在 vite build 后不入 dist, preview/静态托管下 404 → 设计器裸样式。改由 src/editor/main.tsx import, rollup 收集进 dist/assets/*.css。dev 不受影响(vite 转译同源)。 注:amis-ui/amis-editor-core 的 exports 字段不暴露 css 子路径,裸包名 import 被 rollup 拒绝, 故用相对 node_modules 路径直引真实 css 文件。 REQUIRED-before-any-hosted-demo, OPTIONAL-for-pure-dev。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,10 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>EIP4 页面设计器</title>
|
<title>EIP4 页面设计器</title>
|
||||||
<!-- amis-editor 独立入口:用 npm 包版 amis,与主应用 sdk-local 完全隔离 -->
|
<!-- amis-editor 独立入口:用 npm 包版 amis,与主应用 sdk-local 完全隔离 -->
|
||||||
<!-- CSS 在 HTML 里直接引用,绕开 vite esbuild 对 amis-ui 包路径的解析 -->
|
<!-- CSS 由 src/editor/main.tsx import 引入(vite build 收集进 dist,避免绝对包路径在生产构建 404)-->
|
||||||
<link rel="stylesheet" href="/node_modules/amis-editor-core/lib/style.css" />
|
|
||||||
<link rel="stylesheet" href="/node_modules/amis-ui/lib/themes/default.css" />
|
|
||||||
<link rel="stylesheet" href="/node_modules/amis-ui/lib/helper.css" />
|
|
||||||
<style>
|
<style>
|
||||||
html, body, #editor-root { height: 100%; margin: 0; overflow: hidden; }
|
html, body, #editor-root { height: 100%; margin: 0; overflow: hidden; }
|
||||||
/* amis-editor 自带 CSS 未把 .ae-Editor 约束到容器高度 → 它按内容自然撑高(高页面如
|
/* amis-editor 自带 CSS 未把 .ae-Editor 约束到容器高度 → 它按内容自然撑高(高页面如
|
||||||
|
|||||||
@@ -6,6 +6,16 @@
|
|||||||
// 异步(markReady / calculateHighlightBox)随后打到已死实例 → 抛
|
// 异步(markReady / calculateHighlightBox)随后打到已死实例 → 抛
|
||||||
// 「[mobx-state-tree] object no longer part of a state tree」→ 编辑器整片空白。
|
// 「[mobx-state-tree] object no longer part of a state tree」→ 编辑器整片空白。
|
||||||
// 主应用 main.tsx 跑 amis SDK(运行时渲染器,容忍 StrictMode),唯独 amis-editor 不行。
|
// 主应用 main.tsx 跑 amis SDK(运行时渲染器,容忍 StrictMode),唯独 amis-editor 不行。
|
||||||
|
//
|
||||||
|
// CSS 由此处 import 引入(不再用 editor.html 的 /node_modules 绝对 link):
|
||||||
|
// vite dev 直接转译、vite build 由 rollup 收集进 dist 的 css 产物,
|
||||||
|
// 修掉「dist/editor.html 三条 /node_modules link 在 preview/静态托管下 404」。
|
||||||
|
// 注:amis-ui/amis-editor-core 的 package.json exports 字段不暴露这些 css 子路径,
|
||||||
|
// 用裸包名 import 会被 rollup 拒绝解析(同 vite.config 注释里 amis 栈无 exports 之坑),
|
||||||
|
// 故以相对 node_modules 路径直引这三个真实 css 文件,绕开包解析。
|
||||||
|
import '../../node_modules/amis-editor-core/lib/style.css';
|
||||||
|
import '../../node_modules/amis-ui/lib/themes/default.css';
|
||||||
|
import '../../node_modules/amis-ui/lib/helper.css';
|
||||||
import { createRoot } from 'react-dom/client';
|
import { createRoot } from 'react-dom/client';
|
||||||
import { DesignerPage } from './DesignerPage';
|
import { DesignerPage } from './DesignerPage';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user