Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
62 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,62 @@ | ||
|
||
JBundle.config do | ||
|
||
end | ||
|
||
|
||
version 2 | ||
dist 'dist' | ||
|
||
bundle :some_file do | ||
file 'file1' | ||
file 'file2 | ||
end | ||
|
||
file 'file3' | ||
|
||
filter do |src| | ||
src.gsub /<VERSION>/, version | ||
end | ||
|
||
dist/2/some_file.js | ||
dist/2/some_file.min.js | ||
dist/2/file3.js | ||
dist/2/file3.min.js | ||
|
||
## JBundle (in progress) | ||
|
||
Define a set of javascript files to bundle and minify | ||
|
||
JBundle.config do | ||
version '1.6.1' | ||
|
||
src_dir File.dirname(__FILE__) + '/src' | ||
|
||
bundle 'foo.js' do | ||
file 'file1.js' | ||
file 'file2.js' | ||
end | ||
|
||
bundle 'foo2.js' do | ||
file 'file3.js' | ||
file 'file4.js' | ||
end | ||
|
||
file 'file4.js' | ||
|
||
file 'text.txt' | ||
# Filters can be use for string substitution | ||
filter do |src, config| | ||
src.gsub!(/<VERSION>/, config.version) | ||
end | ||
|
||
end | ||
|
||
Then write them to a directory | ||
|
||
JBundle.write_to './dist' | ||
|
||
This will write the following files: | ||
|
||
'dist/1.6.1/foo.js' | ||
'dist/1.6.1/foo.min.js' | ||
'dist/1.6.1/foo2.js' | ||
'dist/1.6.1/foo2.min.js' | ||
'dist/1.6.1/file4.js' | ||
'dist/1.6.1/file4.min.js' | ||
'dist/1.6.1/text.txt' | ||
|
||
'dist/1.6/foo.js' | ||
'dist/1.6/foo.min.js' | ||
'dist/1.6/foo2.js' | ||
'dist/1.6/foo2.min.js' | ||
'dist/1.6/file4.js' | ||
'dist/1.6/file4.min.js' | ||
'dist/1.6/text.txt' | ||
|
||
Or you can build a single bundle/file dinamically (ie. for testing) | ||
|
||
JBundle.build('foo.js').src | ||
|
||
Or | ||
|
||
JBundle.build('foo.js').min | ||
|
||
All defined filters will run on the src for all these cases. | ||
|