承接 gymmed/bagisto-vite-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

gymmed/bagisto-vite-parser

Composer 安装命令:

composer require gymmed/bagisto-vite-parser

包简介

Neat way to locate documents build with vite laravel library in bagisto project. Helps to find manifest.json while using config/bagisto-vite.

README 文档

README

Bagisto Vite Parser


Parses bagisto vite document.

Neat way to locate documents build with vite laravel library in bagisto project. Helps to find manifest.json while using config/bagisto-vite.

Installation

You can install the package via composer:

composer require gymmed/bagisto-vite-parser

Use Case

Dompdf and its laravel wrapper, laravel-dompdf, only support direct CSS or external CSS file links. However, these CSS files require real relative paths, while Vite in Laravel uses hashed filenames to avoid name collisions. This library provides an easy way to retrieve the correct CSS paths from config/bagisto-vite, specifically designed for Bagisto, not for general Laravel usage.

Usage

In your config/bagisto-vite.php, add a new entry for your package under the viters section. Example:

    return [
        'viters' => [
            ...
            'myNamespace' => [
                'hot_file'                 => 'myNamespace-default-vite.hot',
                'build_directory'          => 'themes/myNamespace/default/build',
                'package_assets_directory' => 'src/Resources/assets',
            ],
        ],
    ];

This should correspond to the laravel plugin configuration in your package's vite.config.js. Example:

plugins: [
    ...
    vue(),

    laravel({
        hotFile: "../../../public/myNamespace-default-vite.hot",
        publicDirectory: "../../../public",
        buildDirectory: "themes/myNamespace/default/build",
        input: [
            "src/Resources/assets/css/app.css",
            "src/Resources/assets/js/app.js",
        ],
        refresh: true,
    }),
],

To get documents real paths we write:

use GymMed\BagistoViteParser;

//provide full path
$viteDocumentsPaths = BagistoViteParser::getDocumentsPaths(
    [
        'src/Resources/assets/css/app.css',
        'src/Resources/assets/js/app.js'
    ],
    'myNamespace'
);

returned results:

array:2 [▼
  0 => "...\bagisto\public\themes/myNamespace/befault/build/assets/app-2bf84331.css"
  1 => "...\bagisto\public\themes/myNamespace/default/build/assets/app-c35c0f3a.js"
]

and you can get single document path:

use GymMed\BagistoViteParser;

//provide full path
$viteDocumentsPaths = BagistoViteParser::getDocumentPath(
    'src/Resources/assets/css/app.css',
    'myNamespace'
);

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-30