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
- If you haven't already, create a
package.jsoninside your project root:npm init -y - Install Laravel Mix:
npm install laravel-mix --save-dev - Copy the
webpack.mix.jsfile 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
Credits
The idea behind this originally came from the
mixBlade 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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2019-02-19