@uniweb /运行时
加载Uniweb基础和编排渲染的最小运行时间。
概述
这个包为Uniweb站点提供浏览器端运行时。它动态加载基础,并使用React Router渲染内容。
有关Vite构建插件,请参见 @uniweb/build.
安装
npm install @uniweb/runtime
使用
运行时加载
使用Foundation URL初始化运行时:
import initRuntime from '@uniweb/runtime'
// Load foundation from URL
initRuntime('/foundation/foundation.js', {
development: import.meta.env.DEV,
})
// Or with CSS
initRuntime({
url: '/foundation/foundation.js',
cssUrl: '/foundation/assets/style.css'
})
静态绑定
基金会直接导入并与网站捆绑:
import * as Foundation from '@my-org/my-foundation'
import initRuntime from '@uniweb/runtime'
initRuntime(Foundation)
API
initRuntime(来源、期权)
使用基础初始化运行时。
源 -其中之一:
- 基础模块的URL字符串
- 对象与
{ url, cssUrl } - 基础模块对象(用于静态捆绑)
选项:
{
development: false, // Enable dev mode (StrictMode, verbose errors)
configData: null, // Site content (or reads from DOM)
basename: undefined // React Router basename
}
对于核心课程(Uniweb, Website, Block等),从 @uniweb/core.
体系结构
@uniweb/runtime (browser)
│
├── Loads foundation dynamically
├── Creates Uniweb instance via @uniweb/core
└── Orchestrates React/Router rendering
基础:
- 从
@uniweb/kit(捆绑) - 马克
@uniweb/core作为外部(由运行时提供)
构建插件
Vite插件已经移动到 @uniweb/build:
// vite.config.js
import { siteContentPlugin } from '@uniweb/build/site'
import { foundationDevPlugin } from '@uniweb/build/dev'
export default defineConfig({
plugins: [
siteContentPlugin({ sitePath: './', inject: true }),
foundationDevPlugin({ path: '../foundation', serve: '/foundation' }),
]
})
相关的包
@uniweb/core-核心课程(Uniweb, Website, Block)@uniweb/kit-用于基础的组件库@uniweb/build- Vite构建插件uniweb—用于创建项目的CLI
许可证
Apache 2.0