blevins/laravel-assets 问题修复 & 功能扩展

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

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

blevins/laravel-assets

Composer 安装命令:

composer require blevins/laravel-assets

包简介

A super simple script and stylesheet management package for Laravel 4.

README 文档

README

A super simple external JavaScript and Stylesheet management package for Laravel 4.

Installation

Add the package dependency to your project's composer.json file.

"require": {
	"laravel/framework": "4.1.*",
	"blevins/laravel-assets": "dev-master"
},

Run composer update and add 'Blevins\Assets\AssetsServiceProvider' to the app/config/app.php service providers array.

Configuration

Add an assets.php to your app/config directory. Specify environment configurations by adding an assets.php to each environment directory in your app/config directory.

There is no limit to the number of stylesheets or external scriptd. At least one media type is required as a key in the styles array.

<?php

return array(

	'scripts' => array(
		'/path/to/script/file-1.js',
		'/path/to/script/file-2.js',
		[ ..., ]
	),

	'styles' => array(
		'all' => array(
			'/path/to/stylesheet/file-1.js',
			'foo' => '/path/to/stylesheet/file-2.js',
			[ ..., ]
		),
		'screen' => array(
			'/path/to/stylesheet/file-3.js',
			[ ..., ]
		),
		'print' => array(
			'/path/to/stylesheet/file-4.js',
			[ ..., ]
		),
	),
);

The following example includes all stylesheets and scrtips defined in assets.php.

<html>
	<head>
		{{ styles() }}
		{{ scripts() }}
	</head>
</html>
<html>
	<head>
		<link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-1.js">
		<link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-2.js">
		<link media="screen" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-3.js">
		<link media="print" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-4.js">
		<script src="/path/to/script/file-1.js"></script>
		<script src="/path/to/script/file-2.js"></script>
	</head>
</html>

But what if you need specific stylesheets or combination of stylesheets for different templates? The next example shows how to use the media type and dot notation to include specific stylesheets.

<html>
	<head>
		{{ styles(array('all.foo', 'print')) }}
	</head>
</html>
<html>
	<head>
		<link media="all" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-2.js">
		<link media="print" type="text/css" rel="stylesheet" href="/path/to/stylesheet/file-4.js">
	</head>
</html>

Example

Local: app/local/assets.php

<?php

return array(

	'scripts' => array(
		'/assets/libs/requirejs/require.js',
		'/assets/core/lib/main.js',
	),

	'styles' => array(
		'screen' => array(
			'/assets/core/css/style.css',
		),
	),
);

Default: app\assets.php

<?php

return array(

	'scripts' => array(
		'/assets/build/lib/main.js',
	),

	'styles' => array(
		'screen' => array(
			'/assets/build/css/style.css',
		),
	),
);

统计信息

  • 总下载量: 120
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2013-12-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固