networkteam/neos-vite
Composer 安装命令:
composer require networkteam/neos-vite
包简介
Integrate Vite for asset bundling into Neos CMS
README 文档
README
Compatibility
| NeosCMS | Plugin |
|---|---|
| >= 9.0 | 1.x |
| 8.x | 0.3.x |
Installation
Go to your site package:
cd DistributionPackages/Your.Site
1. Install the package via composer
composer require networkteam/neos-vite
2. Install Vite via NPM (or Yarn, pnpm):
npm install --save-dev vite
3. Create a vite.config.mjs file in your site package:
import { defineConfig } from "vite"; export default defineConfig((configEnv) => ({ base: "./", build: { // generate .vite/manifest.json in outDir manifest: true, rollupOptions: { // overwrite default .html entry input: { footer: "Resources/Private/Javascript/footer.js", header: "Resources/Private/Javascript/header.js", }, output: { // The Flowpack.CacheBuster package adds a `?bust` get parameter with a hash based on the file content. // This leads to issues with files imported from the manifest, as they may be loaded twice. // (Once with the bust parameter and once without, as they are technically two different URLs.) // To work around this we add a "bust" infix so CacheBuster skips adding the bust parameter. entryFileNames: "assets/[name]-bust-[hash].js", // If you use this output option the Fusion object will just work™️ dir: "Resources/Public/Dist", }, }, }, }));
4. You can now include Vite assets for development / production in your Fusion files:
header = Networkteam.Neos.Vite:Asset {
entry = 'Resources/Private/Javascript/header.js'
}
This Fusion object will use a different include based on the FLOW_CONTEXT:
- Development: Loads entry from development server configured for the site (defaults to http://localhost:5173/)
- Production: Based on the generated manifest file it will include the hashed assets with CSS and recursive imports
By default the manifest is expected in Resources/Public/Dist, but that can be changed by overriding Fusion properties:
prototype(Networkteam.Neos.Vite:Asset) {
// ...
outputPathPattern = 'resource://{sitePackageKey}/Public/Dist'
manifest = '.vite/manifest.json'
}
Bonus: You can generate the URL to entries in the manifest
This will only return the URL to the file for an entry without considering imports.
Example for an SVG spritemap (using vite-plugin-svg-spritemap):
src = Networkteam.Neos.Vite:AssetUrl {
entry = 'spritemap.svg'
}
Multi-site
Configure individual Vite configurations for each site by adding a Vite setup with a corresponding vite.config.mjs file in each site package.
Make sure to run each server on a different port by configuring the server.port option in the Vite configuration.
Add Settings for each site in your Settings.yaml:
Networkteam: Neos: Vite: server: # This is the default setting if no configuration part is found for the site package key _default: url: http://localhost:5173/ # Specify server configuration for a specific site package key MyExample.Site: url: http://localhost:5174/
Make sure to run multiple Vite servers for each site package.
networkteam/neos-vite 适用场景与选型建议
networkteam/neos-vite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.01k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2024 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 networkteam/neos-vite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 networkteam/neos-vite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-05