承接 mindkomm/theme-lib-mix 相关项目开发

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

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

mindkomm/theme-lib-mix

Composer 安装命令:

composer require mindkomm/theme-lib-mix

包简介

Laravel Mix functions for WordPress projects

README 文档

README

A Laravel Mix function for WordPress themes.

The mix() function is useful if you want to enable cache busting for your theme asset files (CSS, JavaScript, images, icon sprites). Laravel Mix allows you to create a mix-manifest.json file, which might look like this:

{
    "/css/styles.css": "/css/styles.css?id=6ed48b0b831e80bd7549",
    "/js/scripts.js": "/js/scripts.js?id=1bdd07b944e933aa88aa",
}

The ID parameter is a hash of the file contents that changes every time that you make a change to a file. The mix(), mix_child() and mix_any() functions provided in this package allow you to use these hashed URLs for enqueueing your assets in your WordPress theme.

Installation

You can install the package via Composer:

composer require mindkomm/theme-lib-mix

Usage

The mix() function assumes that you have a mix-manifest.json (generated by the version function of Laravel Mix) in the build folder of your theme.

add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style(
        'styles',
        mix( 'build/css/styles.css' )
    );
} );

If the mix function can’t find your asset file in the manifest file, it will return the asset URL through get_theme_file_uri as a fallback.

Functions

Name Return Type Summary/Returns
mix() string Gets the path to a versioned Mix file in a theme.

Returns: The versioned file URL.
mix_child() string Gets the path to a versioned Mix file in a child theme.

Returns: The versioned file URL.
mix_any() string Gets the path to a versioned Mix file outside of your theme folders.

Returns: The versioned file URL.

mix()

Gets the path to a versioned Mix file in a theme.

Use this function if you want to load theme dependencies. This function will cache the contents of the manifest files for you.

  • If you want to use mix in a child theme, use mix_child().
  • If you want to use mix outside of your theme folder, you can use mix_any().

since 1.0.0

mix( string $path, array $args = [] )

Returns: string The versioned file URL.

Name Type Description
$path string The relative path to the file.
$args array Optional. An array of arguments for the function.
  • (bool) $is_child – Whether to check the child directory first. Default false.
  • (string) $manifest_directory – Custom relative path to manifest directory. Default build.
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style(
        'styles',
        mix( 'build/css/styles.css' )
    );
} );

mix_child()

Gets the path to a versioned Mix file in a child theme.

Similar to mix(), but tries to load a file from the child theme first.

since 1.2.0

mix_child( string $path, array $args = [] )

add_action( 'wp_enqueue_scripts', function() {
	wp_enqueue_style(
		'theme-styles-child',
		mix_child( 'build/css/styles-child.css' ),
		[],
		null
	);
} );

mix_any()

Gets the path to a versioned Mix file outside of your theme folders.

The difference to the mix() function is that for this function, you need to provide the absolute paths to the file and the manifest directory. The benefit is that it’s more versatile and that you can use it for functionality that might not live in a theme, but in a plugin, vendor packages or in a symlinked package.

since 1.1.0

mix_any( string $path, string $manifest_directory, string $manifest_name = mix-manifest.json )

Returns: string The versioned file URL.

Name Type Description
$path string The full path to the file.
$manifest_directory string The full path to the manifest directory.
$manifest_name string Optional. The name of the manifest file in $manifest_directory. Default mix-manifest.json.

Support

This is a library that we use at MIND to develop WordPress themes. You’re free to use it, but currently, we don’t provide any support.

mindkomm/theme-lib-mix 适用场景与选型建议

mindkomm/theme-lib-mix 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46.28k 次下载、GitHub Stars 达 35, 最近一次更新时间为 2018 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 mindkomm/theme-lib-mix 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 46.28k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 35
  • 点击次数: 9
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 35
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-02-13