Componette

Componette

frontpack

frontpack / composer-assets-plugin v0.11.0

Composer plugin for copying of frontend assets into public directory.

download-cloud-line composer require frontpack/composer-assets-plugin

Composer Assets Plugin

Composer plugin for installing assets.

Donate

Installation

Use Composer:

composer require frontpack/composer-assets-plugin

Library requires PHP 5.6.0 or later.

Commands

  • composer refresh-assets - refresh files in assets directory

Assets configuration

Packages

  • assets-files in section extra
    • true - symlinks whole package directory
    • file path - symlinks one file or content of directory
    • list of file paths - symlinks files/directories

Example:

{
	"extra": {
		"assets-files": [
			"static/plugin.js",
			"static/plugin.css",
			"static/icons.png"
		]
	}
}
  • static/plugin.js - symlinks file to assets/org/package/plugin.js
  • static/plugin.css - symlinks file to assets/org/package/plugin.css
  • static/icons.png - symlinks file to assets/org/package/icons.png

Or you can use simple:

{
	"extra": {
		"assets-files": "static"
	}
}

with same result.

Root package

  • assets-dir - directory for installing of assets, default assets, relative to vendor-dir
  • assets-directory - alias for assets-dir
  • assets-files - list of asset files in incompatible packages, it overrides assets-files from installed packages
  • assets-strategy - install strategy for assets
    • auto - select strategy by platform (default value)
    • copy - copy all assets, default strategy on Windows
    • symlink - create relative symlinks, default strategy on non-Windows platforms
  • assets-target - target directory for specific packages, relative to vendor-dir, must be out of assets-dir

Example:

{
	"extra": {
		"assets-dir": "public",
		"assets-files": {
			"org/package": true,
			"org/package2": "js/calendar.js",
			"org/package3": [
				"static/plugin.js",
				"static/plugin.css",
				"static/icons.png"
			]
		},
		"assets-target": {
			"ckeditor/ckeditor": "admin/wysiwyg"
		}
	}
}
  • org/package - symlinks whole package directory to public/org/package
  • org/package2 - symlinks file js/calendar.js to public/org/package2/calendar.js
  • org/package3
    • static/plugin.js - symlinks file to public/org/package3/plugin.js
    • static/plugin.css - symlinks file to public/org/package3/plugin.css
    • static/icons.png - symlinks file to public/org/package3/icons.png
  • ckeditor/ckeditor - symlinks files to admin/wysiwyg

Default mapping

Plugin provides default mapping for selected incompatible packages. You can override this mapping in your composer.json.

List of packages with default mapping:

  • bower-asset/tiny-slider
  • ckeditor/ckeditor
  • components/jquery
  • enyo/dropzone
  • nette/forms
  • o5/grido

Where find supported packages?

Some libraries and packages support Composer by default. For other exists shim-repositories:

Always you can search packages on Packagist.


License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/

  • v0.11.0 Version 0.11.0

    • added support for Composer 2.0
  • v0.10.2 Version 0.10.2

    • DefaultMapping: added bower-asset/tiny-slider
  • v0.10.1 Version 0.10.1

    • AssetsInstaller - fixed fetching of config.assets-dir
  • v0.10.0 Version 0.10.0

    • modified processing if assets-files is only directory (BC BREAK)
    • requires PHP 5.6 or newer
    • changed config.assets-* to extra.assets-*
    • throws exception if creating of directory failed (#10)
  • v0.9.4 Version 0.9.4

    • fixed some undefined variables
  • v0.9.3 Version 0.9.3

    • added option assets-target (see #3)
    • added default mapping for ckeditor/ckeditor
    • assets-directory is always normalized
    • processFile() - directory name is trimmed
    • print info for whole packages
  • v0.9.2 Version 0.9.2

    • added support for "install strategies" (#1)
  • v0.9.1 Version 0.9.1

    • added default mapping for selected incompatible packages
    • updated README
  • v0.9.0 Version 0.9.0

    First public release.

bar-chart-fill

Statistics

download-cloud-fill
28497
star-fill
25
bug-fill
3
flashlight-fill
1y
price-tag-2-line

Badges

guide-fill

Dependencies

php (>=5.4.0)
Componette Componette felix@nette.org