diverently/laravel-mix-kirby 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

diverently/laravel-mix-kirby

Composer 安装命令:

composer require diverently/laravel-mix-kirby

包简介

Laravel Mix helper for the Kirby CMS

README 文档

README

Use the mix helper function to get the correct path to your versioned CSS and JS files generated by Laravel Mix.

Installation

Download

Download and copy this repository to site/plugins/laravel-mix-kirby.

Git submodule

git submodule add https://github.com/Diverently/laravel-mix-kirby.git site/plugins/laravel-mix-kirby

Composer

composer require diverently/laravel-mix-kirby

Laravel Mix

You should also install Laravel Mix, otherwise this plugin is pretty useless ;-) See the installation guide for further information, though it's actually pretty straight forward:

Setup

In your site/config/config.php you can set two options to make this helper work with your specific setup:

diverently.laravel-mix-kirby.manifestPath

This is where the helper function will look for the manifest created by Laravel Mix.

Default: assets/mix-manifest.json

diverently.laravel-mix-kirby.assetsDirectory

This will be prepended to the individual file paths given to the mix() function when creating the final HTML tags.

Default: assets

Options

mix() helper function

The mix() helper function reads the mix-manifest.json file and returns the right HTML tag with the correct path to the requested file. In our example we would call it like so:

<html>
<head>
    <!-- ... -->
    <?php echo mix('/main.css') ?>
    <?php echo mix([
      '/additional.css',
      '@autocss'
    ]) ?>
</head>
<body>
    <!-- ... -->
    <?php echo mix('/main.js') ?>
    <?php echo mix([
      '/additional.js',
      '@autojs'
    ]) ?>
</body>
</html>

And that's it, actually.

Development

  1. If you haven't already, create a package.json inside your project root: npm init -y
  2. Install Laravel Mix: npm install laravel-mix --save-dev
  3. Copy the webpack.mix.js file into your root: cp node_modules/laravel-mix/setup/webpack.mix.js ./

After that you can start using Laravel Mix in your project.

webpack.mix.js

See the official documentation for more information.

let mix = require("laravel-mix")
mix.setPublicPath("assets")
mix.browserSync("my-website.dev")
if (mix.inProduction()) {
  mix.version()
}
mix
  .sourceMaps()
  .js("src/js/main.js", "assets")
  .sass("src/css/main.scss", "assets")

NPM scripts

Add the following NPM scripts to your package.json:

"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
}

License

MIT

Credits

Robert Cordes

Diverently

The idea behind this originally came from the mix Blade helper created for the Laravel framework. This is merely a "translation" for the Kirby CMS, only that it also generates the correct HTML tag depending on what file type you request.

diverently/laravel-mix-kirby 适用场景与选型建议

diverently/laravel-mix-kirby 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.36k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2019 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 diverently/laravel-mix-kirby 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 23
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-19