./README.md in lux_assets-0.1.10 vs ./README.md in lux_assets-0.2.1
- old
+ new
@@ -11,11 +11,11 @@
* add rake tasks
## Instalation
Add `lux_assets` gem to `Gemfile` and then `bundle install`
-```
+```ruby
gem 'lux_assets'
```
## Using
@@ -60,11 +60,11 @@
```
## Example ./config/assets.rb
-```
+```ruby
# relative_root './app/assets'
asset :admin do
js do
add 'js/admin/js_vendor/*' # will add all files from a folder
@@ -99,22 +99,68 @@
* list of files
* proc
If you add proc, proc retun must be a string, not a file
+## API usage - all you need to know
+### In your code
+
+```ruby
+require 'lux_assets'
+
+# Get list of files defined in config
+LuxAssets.to_s[:js]
+LuxAssets.files(:js, :main)
+LuxAssets.files('js/main')
+LuxAssets.js(:main).files
+
+# compile single asset
+LuxAssets.compile('js/main/index.coffee')
+LuxAssets.compile('css/main/index.scss')
+
+# compile file group
+LuxAssets.js(:main).compile
+LuxAssets.css(:main).compile
+
+# compile all assets
+LuxAssets.compile_all do |name, path|
+ puts "Compile #{name.green} -> #{path}"
+end
+```
+
+### In config/assets.rb
+
+```ruby
+# root for relative files
+relative_root './app/assets'
+
+asset :admin do
+ js do
+ add 'js/admin/js_vendor/*'
+ add 'js/admin/js/*'
+ add 'js/shared/*'
+ add 'js/admin/index.coffee'
+ end
+
+ css do
+ add 'css/admin/index.scss'
+ end
+end
+```
+
## Extending
### Adding processor for new file type
This is all that is needed to add support for TypeScript compilation.
```
yarn add typescript
```
-```
+```ruby
class LuxAssets::Element
def compile_ts
system "node_modules/typescript/.bin/tsc --outFile '#{@cache}' '#{@source}'"
end
end
@@ -122,11 +168,11 @@
### Added new plugin for file adder
You need to extend `LuxAssets` class and call method `add` with list of files or a proc.
-```
+```ruby
module LuxAssets
# include files from a plugin
def plugin name
plugin = Lux.plugin.get name
add '%s/**' % plugin[:folder]
@@ -140,10 +186,10 @@
In `Rakefile` just add `require 'lux_assets'` and tasks will automaticly be added to your list of tasks.
Rake taks will call :env task to set up environment.
-```
+```ruby
# Rakefile
require 'lux_assets'
task :env do