torann/baun-asset-manifest
Composer 安装命令:
composer require torann/baun-asset-manifest
包简介
A Baun plugin that adds gulp asset manifest helper
README 文档
README
A Baun plugin that adds gulp asset manifest helper
Installation
From the command line run:
$ composer require torann/baun-asset-manifest
Once installed you need to register the plugin with the application. Open up config/plugins.php append the plugin namespace.
<?php return [ ... 'Torann\AssetManifest\Manifest', ];
Asset directory
Add the asset directory name, relative to the public directory, in you config/app.php file.
<?php return [ ... // Assets folder name 'assets_dir' => 'assets', ];
Assets using Gulp
Example gulp file that creates the manifest JSON file when gulp --env=production is ran.
var gulp = require('gulp'), gulpif = require('gulp-if'), less = require('gulp-less'), concat = require('gulp-concat'), minifyCSS = require('gulp-minify-css'), uglify = require('gulp-uglify'), watch = require('gulp-watch'), rename = require('gulp-rename'), argv = require('yargs').argv, prefix = require('gulp-autoprefixer'), rev = require('gulp-rev'); // Options var options = { target: argv.target || 'public/assets', env: argv.env || 'local' }; // Is a production build var IS_PROD_BUILD = (options.env === 'production'); // Error catcher function swallowError (err) { console.error(err); throw err; } // Compile Less and save to stylesheets directory gulp.task('less', function () { var destDir = options.target + '/css/', destFile = 'app.css'; return gulp.src('resources/assets/less/app.less') .pipe(less()) .on('error', swallowError) .pipe(prefix('last 2 versions', '> 1%', 'Explorer 7', 'Android 2')) .pipe(gulpif(IS_PROD_BUILD, minifyCSS())) .pipe(rename(destFile)) .pipe(gulp.dest(destDir)); }); // Publish JavaScript gulp.task('scripts', function () { var destDir = options.target + '/js/', destFile = 'app.js'; return gulp.src([ 'resources/assets/js/main.js' ]) .on('error', swallowError) .pipe(concat(destFile)) .pipe(gulpif(IS_PROD_BUILD, uglify())) .pipe(gulp.dest(destDir)); }); // What tasks does running gulp trigger? gulp.task('default', ['build']); gulp.task('watch', ['build'], function() { gulp.watch('resources/assets/less/**/*.less', ['less']); gulp.watch('resources/assets/js/**/*.js', ['scripts']); }); gulp.task('build', ['less', 'scripts'], function () { // Create manifest of assets if (IS_PROD_BUILD) { return gulp.src(options.target + '/**/*.{css,js}') .pipe(gulp.dest(options.target)) .pipe(rev()) .pipe(gulp.dest(options.target)) .pipe(rev.manifest()) .pipe(gulp.dest('./')); } });
Usage
Inside a template you can simple use {{ asset('css/app.css') }} to get the asset from the manifest file.
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
torann/baun-asset-manifest 适用场景与选型建议
torann/baun-asset-manifest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「baun」 「baun plugin」 「baun gulp」 「baun assets」 「baun manifest」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 torann/baun-asset-manifest 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 torann/baun-asset-manifest 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 torann/baun-asset-manifest 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
The task manager for PHP
The Baun Framework
Composer Plugin for Drupal 8 to create a new theme with SASS compiler based on Gulp
Tool to have a dashboard of component of the app.
A modern, lightweight, extensible CMS for PHP
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD
- 更新时间: 2015-10-31