定制 crazy252/typo3_vite 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

crazy252/typo3_vite

Composer 安装命令:

composer require crazy252/typo3_vite

包简介

Vite for Typo3

README 文档

README

This open source project provides a bridge between Vite.js and Typo3 to make development and deployment of modern web applications easier and more efficient. It allows Typo3 users to leverage the power of Vite.js's fast and modular development experience in their projects. It offers an easy-to-use interface for integrating Vite.js into Typo3 and enables developers to take full advantage of Vite.js's modern features, such as hot module replacement, tree-shaking, and code splitting. It's a perfect way to give your Typo3 project the modern web development experience it deserves!

Setup

Add a package.json file to your extension or add the following dependencies to your file.

{
    "name": "extension_name",
    "private": true,
    "version": "0.0.1",
    "scripts": {
        "dev": "vite --host 0.0.0.0",
        "build": "vite build",
        "preview": "vite preview"
    },
    "devDependencies": {
        "vite": "^4.4.11"
    }
}

Add a vite.config.js file to your extension. If you don't use ddev as environment you can remove the https object in the config.

You are free to change the input and output paths and the alias. If you change the paths, you also need to change your paths in the typoscript configuration.

import fs from 'fs'
import path from 'path'
import { defineConfig } from 'vite'

/** @type {import('vite').UserConfig} */
const config = {
    server: {
        port: 5173,
        https: {
            key: fs.readFileSync('/etc/ssl/certs/master.key'),
            cert: fs.readFileSync('/etc/ssl/certs/master.crt'),
        }
    },
    base: '',
    publicDir: 'fake_dir_so_nothing_gets_copied',
    build: {
        manifest: true,
        outDir: 'Resources/Public',
        rollupOptions: {
            input: [
                'Resources/Private/Frontend/main.js',
            ]
        }
    },
    resolve: {
        alias: [
            {
                find: '@',
                replacement: path.resolve(__dirname + '/Resources/Private/Frontend/')
            }
        ]
    },
    plugins: [
        {
            name: 'html',
            handleHotUpdate({file, server}) {
                if (file.endsWith('.html')) {
                    server.ws.send({
                        type: 'full-reload',
                        path: '*'
                    });
                }
            }
        }
    ]
}

export default defineConfig(config)

Extend your TypoScript with your configuration. You can use the template setup in the backend or your setup.typoscript file for that.

The port need to be the same as in the vite.config.js.

plugin.tx_typo3vite.settings.extension_name {
    port = 5173
    out = Resources/Public
    src = Resources/Private/Frontend
}

Add the viewhelpers in your page template to use your bundled files. The entry is the filename of the input files from the vite.config.js.

{namespace vite=Crazy252\Typo3Vite\ViewHelpers}

<vite:asset extension="extension_name" entry="main.js" />

And now it's done. Start the dev server in your extension folder via yarn dev or other javascript package managers.

After that, you can view your site with the ?no_cache=1 and you got the full power of vite.js in typo3!

React setup

If you want to use react in your frontend, you need to add the following viewhelper in your page template.

<vite:react extension="extension_name" />

Extension setup

If you want to change the domain, url, timeout and other settings you can change it via the typoscript setup. Here are the possible settings with the default values.

plugin.tx_typo3vite.settings.extension_name {
    out = null                    # path to the output folder
    src = null                    # path to the src folder

    domain = https://127.0.0.1    # default domain of vite server
    port = 3000                   # default port of vite server
    uri = /@vite/client           # default uri for vite client
    timeout = 1.0                 # timeout for dev server check
    verify = false                # ssl certificate verification
}

DDEV setup

If you use ddev as environment, you need to extend ddev with a port for the vite dev server. Create a file in the .ddev folder named docker-compose.ports.yaml and add the following content.

version: '3.6'

services:
  web:
    ports:
      - "127.0.0.1:5173:5173"

crazy252/typo3_vite 适用场景与选型建议

crazy252/typo3_vite 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 273 次下载、GitHub Stars 达 7, 最近一次更新时间为 2023 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 crazy252/typo3_vite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 crazy252/typo3_vite 我们能提供哪些服务?
定制开发 / 二次开发

基于 crazy252/typo3_vite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 273
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2023-01-27