drupal-civicrm/sites/all/modules/civicrm/packages/backbone-forms/scripts/build

102 lines
2.6 KiB
Plaintext
Raw Permalink Normal View History

2018-01-14 15:10:16 +02:00
#!/usr/bin/env node
var builder = require('buildify'),
path = require('path');
var templateData = {
version: '0.10.1'
};
var baseDir = __dirname + '/..',
sourceDir = baseDir + '/src',
outputDir = baseDir + '/distribution';
//Files to concatenate into main file
var fileList = [
'form.js',
'helpers.js',
'validators.js',
'field.js',
'editors.js',
'setup.js',
'templates/default.js'
];
//Concatenate the main files
var mainContents = builder(sourceDir)
.concat(fileList)
.getContent();
//Save regular dev and mini versions
builder(baseDir)
.setContent(mainContents)
.wrap('scripts/build-templates/main.js', templateData)
.save('distribution/backbone-forms.js')
.uglify()
.save('distribution/backbone-forms.min.js');
//Main AMD file (for RequireJS)
builder(baseDir)
.setContent(mainContents)
.wrap('scripts/build-templates/main.amd.js', templateData)
.save('distribution.amd/backbone-forms.js')
.uglify()
.save('distribution.amd/backbone-forms.min.js');
//Standalone template files
['default', 'bootstrap'].forEach(function(template) {
//HTML
builder(baseDir)
.load('src/templates/'+template+'.js')
.wrap('scripts/build-templates/standalone-template.js')
.save('distribution/templates/'+template+'.js');
//HTML (AMD)
builder(baseDir)
.load('src/templates/'+template+'.js')
.wrap('scripts/build-templates/standalone-template.amd.js')
.save('distribution.amd/templates/'+template+'.js');
//CSS
builder(baseDir)
.load('src/templates/'+template+'.css')
.save('distribution/templates/'+template+'.css')
.save('distribution.amd/templates/'+template+'.css');
});
//Extra editors
['list', 'jquery-ui'].forEach(function(name) {
//Save regular dev and mini versions
builder(baseDir)
.load('src/editors/'+name+'.js')
.save('distribution/editors/'+name+'.js')
.uglify()
.save('distribution/editors/'+name+'.min.js');
//CSS file
if (path.existsSync(baseDir + '/src/editors/'+name+'.css')) {
builder(baseDir)
.load('src/editors/'+name+'.css')
.save('distribution/editors/'+name+'.css')
.save('distribution.amd/editors/'+name+'.css');
}
//Save AMD version (for RequireJS)
builder(baseDir)
.load('src/editors/'+name+'.js')
.wrap('scripts/build-templates/simple.amd.js')
.save('distribution.amd/editors/'+name+'.js')
.uglify()
.save('distribution.amd/editors/'+name+'.min.js');
});
//Modal adapters
builder(baseDir)
.load('lib/backbone.bootstrap-modal/src/backbone.bootstrap-modal.js')
.save('distribution/adapters/backbone.bootstrap-modal.js')
.uglify()
.save('distribution/adapters/backbone.bootstrap-modal.min.js');