bechir/vite-bundle
Composer 安装命令:
composer require bechir/vite-bundle
包简介
Integrate Vite.js into your Symfony application
README 文档
README
This bundle allows you to integrate Vite into your Symfony application by using WebpackEncoreBundle and ViteFait
Installation
Make sure Node and a package manager (Yarn) are installed.
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require bechir/vite-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php return [ // ... Bechir\ViteBundle\BechirViteBundle::class => ['dev' => true], ];
Add the bundle configuration in config/packages/bechir_vite.yaml:
bechir_vite: output_path: '%kernel.project_dir%/public/dist'
Step 3: Install ViteFait
# using yarn yarn add --dev vite-fait # using npm npm install vite-fait --save-dev
Usage
Create vite.config.js in the root folder and add the following code inside the file:
const ViteFait = require('vite-fait'); ViteFait .setRoot('assets') .setOutputPath('../public/dist') .addEntry('app', './assets/app.js') .addEntry('admin', './assets/admin/app.js'); module.exports = ViteFait.getViteConfig()
Add vite-fait scripts in your package.json
{
"scripts": {
"build": "vite-fait build",
"dev": "vite-fait dev",
}
}
Then run your first build with yarn build or npm run build
It generate entrypoints.json file in public/dist:
{
"entrypoints": {
"app": {
"js": [
"/dist/app.7f38ab96.js"
],
"css": [
"/dist/app.c385b6b3.css"
]
},
"admin": {
"js": [
"/dist/admin.a88436ae.js"
],
"css": [
"/dist/admin.0e68df5b.css"
]
}
}
}
Add the twig functions in templates/base.html.twig:
<html> <head> {{ vite_entry_link_tags('app') }} </head> <body> <!-- html code --> {{ vite_entry_script_tags('app') }} </body> </html>
Read the vite docs for more information
Using Plugins
Read how to use vite plugins first before reading this section
Put your plugins inside the usePlugins method:
const fooPlugin = function() { return { name: 'vite-plugin-foo', configureServer() { console.log('foo'); } } } ViteFait .usePlugins(fooPlugin()) // use array for multiple plugins: [fooPlugin(), barPlugin()]
TODO
- Add tests
- React support
- Vue support
- Documentation
bechir/vite-bundle 适用场景与选型建议
bechir/vite-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 10 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bechir/vite-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bechir/vite-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-06