bluetel/ezplatform-admin-ui-entrypoint-components

一组用于直接从webpack encore entrypoint.json加载资产的行政UI组件

1.1.0 2021-01-26 09:21 UTC

This package is auto-updated.

Last update: 2024-09-26 18:22:19 UTC


README

此包添加了一些新的行政UI组件,用于包含来自entrypoints.json文件的资产,这些资产可以用作Ez平台行政UI组件系统的一部分。当您想在CMS中使用encore生成的资产时,这很有用。

兼容性

目前,这些组件仅在eZ平台3.0+上进行了测试

使用方法

此包添加了3个新的行政UI组件

  • Bluetel\EzEntrypointComponentBundle\Component\EntrypointComponent
  • Bluetel\EzEntrypointComponentBundle\Component\EntrypointCSSComponent
  • Bluetel\EzEntrypointComponentBundle\Component\EntrypointScriptComponent

要使用这些组件,请在您的webpack.config.js文件中添加一个新的入口点。

在我们的示例中,我们将添加一个新的入口点来扩展create_form组件。在我们的webpack配置中添加一个新的入口点会暴露entrypoints.json文件中的webpack资产。

// Webpack.config.js
Encore
    .addEntry('admin_ui_create_form_extend', './src/Resources/public/assets/js/main.js')

当运行webpack时,您的entrypoints.json将根据您从新入口点导出的资产而有所不同

//public/assets/build/entrypoints.json
{
    "admin_ui_create_form_extend": {
      "js": [
        "/assets/build/runtime.js",
        "/assets/build/admin_ui_create_form_extend.js"
      ],
      "css": [
        "/assets/build/admin_ui_create_form_extend.css"
      ]
    }
  },
  ...
}

一旦我们定义了一个新的入口点,您就可以添加一个扩展定义,例如

services:
    app.cms.extend.content_create_form:
      parent: Bluetel\EzEntrypointComponentBundle\Component\EntrypointCSSComponent
      autowire: true
      autoconfigure: false
      arguments:
          $entryName: "admin_ui_create_form_extend"
      tags:
          - { name: ezplatform.admin_ui.component, group: content-create-form-after }

添加此内容将自动添加包含entrypoints.json文件中CSSJS键下所有文件的包含语句。

详细参考

包含一个入口点的所有资产

EntrypointComponent组件包含给定entrypoint.json文件的所有资产。可以向它传递的可用参数包括

  • $entryName 必需的:应包含的入口名称
  • $entrypointName:要使用的入口点集合

仅包含给定入口的JS文件

EntrypointScriptComponent允许您包含在entrypoint.json下js键中给出的所有脚本。所有属性都应用于入口点的所有包含脚本。

可以向它传递的可用参数包括

  • $entryName 必需的:应包含的入口名称
  • $entrypointName:要使用的入口点集合
  • $async:如果脚本应包含为异步或非异步。有关此信息的更多信息,请参阅attr-async
  • $defer:如果脚本应延迟加载。有关此信息的更多信息,请参阅attr-deferred
  • $crossorigin:如果资产应跨源加载或非跨源加载。有关此信息的更多信息,请参阅attr-cross-origin
  • $integrity:用于验证给定资产完整性的元数据。有关此信息的更多信息,请参阅attr-integrity

仅包含给定入口的CSS文件

EntrypointCSSComponent允许您包含在entrypoint.json下css键中给出的所有样式表。所有属性都应用于入口点的所有包含脚本。

可以向它传递的可用参数包括

  • $entryName 必需的:应包含的入口名称
  • $entrypointName:要使用的入口点集合
  • $crossorigin:如果资产应跨源加载或非跨源加载。有关此信息的更多信息,请参阅attr-cross-origin
  • $integrity:用于验证给定资产完整性的元数据。更多信息请参阅 attr-integrity