This repository was archived by the owner on Mar 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed build.json to project.json, added modules
- Loading branch information
Matt Karl
committed
Jan 19, 2015
1 parent
45b84b8
commit a1974a6
Showing
16 changed files
with
222 additions
and
67 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
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
// Filter an array of files and only return the javascript files | ||
isJS: function(file){ return /\.js$/.test(file); }, | ||
|
||
// Filter an array of files and only return CSS and LESS files | ||
isCSS: function(file){ return /\.(less|css)$/.test(file); } | ||
}; |
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
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 |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/** | ||
* Dynamically create the tasks required for processing | ||
* modules. | ||
*/ | ||
module.exports = function(project, config) | ||
{ | ||
var path = require('path'), | ||
_ = require('lodash'), | ||
filters = require(path.join(__dirname, 'filters.js')); | ||
|
||
var moduleTasks = []; | ||
var moduleTasksDebug = []; | ||
|
||
// Loop through the modules and add each one | ||
// to the existing list of tasks, this is more | ||
// maintainable if done dynamically | ||
_.each(project.modules, function(mod, name){ | ||
|
||
// Convert the list of files (shorthand) | ||
// into the more verbose format | ||
if (_.isArray(mod)) | ||
{ | ||
mod = { | ||
output: name, | ||
main: mod, | ||
mainDebug: mod | ||
}; | ||
} | ||
else | ||
{ | ||
mod.mainDebug = mod.mainDebug || mod.main; | ||
} | ||
|
||
var js = _.filter(mod.main, filters.isJS); | ||
var jsDebug = _.filter(mod.mainDebug, filters.isJS); | ||
var css = _.filter(mod.main, filters.isCSS); | ||
var cssDebug = _.filter(mod.mainDebug, filters.isCSS); | ||
|
||
var clean = []; | ||
var output, outputDebug; | ||
|
||
moduleTasks.push('clean:'+name); | ||
moduleTasksDebug.push('clean:'+name); | ||
|
||
if (js) | ||
{ | ||
output = {}; | ||
output['<%= jsFolder %>/' + mod.output + '.js'] = js; | ||
|
||
// Add the build | ||
config.uglify[name] = { | ||
files: output, | ||
options: '<%= uglify.main.options %>' | ||
}; | ||
|
||
// Add to hinting | ||
config.jshint.main.push(js); | ||
|
||
// Add to source maps | ||
config.concat[name] = { | ||
src: jsDebug, | ||
dest: '<%= jsFolder %>/' + mod.output + '.js' | ||
}; | ||
|
||
// The replacements for web | ||
config.replace[name] = { | ||
src: '<%= jsFolder %>/' + mod.output + '.js', | ||
overwrite: true, | ||
replacements: '<%= replace.main.replacements %>' | ||
}; | ||
|
||
// add files to clean | ||
clean.push( | ||
'<%= jsFolder %>/' + mod.output + '.js.map', | ||
'<%= jsFolder %>/' + mod.output + '.js' | ||
); | ||
|
||
config.watch.main.files.push(jsDebug); | ||
config.watch.main.tasks.push( | ||
'concat:'+name, | ||
'replace:'+name | ||
); | ||
|
||
moduleTasks.push('uglify:'+name); | ||
moduleTasksDebug.push( | ||
'concat:'+name, | ||
'replace:'+name | ||
); | ||
} | ||
|
||
if (css) | ||
{ | ||
output = {}; | ||
output['<%= cssFolder %>/' + mod.output + '.css'] = css; | ||
|
||
outputDebug = {}; | ||
outputDebug['<%= cssFolder %>/' + mod.output + '.css'] = cssDebug; | ||
|
||
// Add the Less building | ||
config.less[name]= { | ||
files: output, | ||
options: '<%= less.release.options %>' | ||
}; | ||
|
||
// Add LESS debug building | ||
config.less[name+'Debug'] = { | ||
files: outputDebug, | ||
options: { | ||
sourceMap: true, | ||
sourceMapFilename: '<%= cssFolder %>/' + mod.output + '.css.map', | ||
sourceMapURL: mod.output + '.css.map', | ||
sourceMapBasepath: '<%= cssFolder %>' | ||
} | ||
}; | ||
|
||
// Add the watch css task | ||
config.watch.css.tasks.push('less:'+name+'Debug'); | ||
|
||
// Add files to clean | ||
clean.push( | ||
'<%= cssFolder %>/' + mod.output + '.css.map', | ||
'<%= cssFolder %>/' + mod.output + '.css' | ||
); | ||
|
||
moduleTasks.push('less:'+name); | ||
moduleTasksDebug.push('less:'+name+'Debug'); | ||
} | ||
|
||
// Clean options | ||
config.clean[name] = clean; | ||
}); | ||
|
||
return { | ||
moduleTasks: moduleTasks, | ||
moduleTasksDebug: moduleTasksDebug | ||
}; | ||
}; |
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
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
File renamed without changes.
Oops, something went wrong.