Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scottbedard/script
A package for javascript asset management
https://github.com/scottbedard/script
Last synced: 18 days ago
JSON representation
A package for javascript asset management
- Host: GitHub
- URL: https://github.com/scottbedard/script
- Owner: scottbedard
- Created: 2014-10-02T20:24:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-07T08:29:43.000Z (about 10 years ago)
- Last Synced: 2024-12-08T18:49:43.972Z (25 days ago)
- Language: PHP
- Size: 184 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Script Manager
A Lavavel package for concatenating and minifying javascript assets.
https://packagist.org/packages/bedard/script
##### Adding assets
To add a file to your javascript pipeline, call the add() method and pass in the path to your file(s). By default, these files will use base_path() as it's root.
```php
Script::add(
'path/to/some/asset/foo.js',
'some/other/asset/bar.js'
);
```##### Minifying
By default, your assets will be minified in production environments. If this is not what you would like, there are two ways you can adjust this.The simplest way to do this, is by disabling minification using the minify() method
```php
Script::minify(FALSE);
```The other way you could do this is by changing the environment manually. If this method is not called, the environment will be automatically detected.
```php
Script::environment('local');
```##### Building your asset file
To put all the pieces together, you must run this command before passing to your view.
```php
Script::build();
```One important thing to remember, is that this method will only write a new asset file if it does not already exist. In development environments, a new filename will be created whenever any of the asset files change. In a production environment, a new filename will be created whenever the *file name* of one of the asset files changes.
The best ways to utilize this, is to clear the output directory of old files when you push changes to production, or to tag your js file names with version numbers.
##### Referencing the output
Use the following method to get the location of the finalized javascript file
```php
Script::output();
```