var unique = require('array-uniq');
+/**
+ * Creates an array of file paths that can be passed to `gulp.src()`.
+ * @param {Object} config - Customizer configuration file.
+ * @param {String[]} modules - Modules to include in the file list.
+ * @returns {String[]} Array of file paths.
+ */
module.exports = function(config, modules) {
var files = ['core'];
var utils = [];
}
}
+ // Prune duplicate entries from the list of utility files
utils = unique(utils);
+
+ // Combine foundation.core.js, utilities, and plugins into one array
files = files.concat(utils, libraries);
+ // Format the modules as paths
return files.map(function(file) {
return 'js/foundation.' + file + '.js';
});
@include motion-ui-animations;
*/});
+/**
+ * Generates an entry point Sass file with a custom list of CSS exports and Sass variables.
+ * @param {Object} config - Customizer configuration object.
+ * @param {String[]} modules - Modules to include CSS for.
+ * @param {Object} variables - Sass variable overrides to include. The key is the name of the variable, and the value is the value.
+ * @returns {String} Formatted Sass file.
+ */
module.exports = function(config, modules, variables) {
var CONFIG = config;
var variableList = [];
var CUSTOMIZER_CONFIG;
var MODULE_LIST;
+// Load the configuration file for the customizer. It's a list of modules to load and Sass variables to override
gulp.task('customizer:loadConfig', function() {
+ // Config file with list of all Foundation modules and dependencies
var config = fs.readFileSync('customizer/config.yml');
+
+ // Module file, created from customizer form data
var moduleListPath = path.relative(__dirname, path.join(process.cwd(), ARGS.modules));
var moduleList = require(moduleListPath);
VARIABLE_LIST = moduleList.variables;
});
+// Creates a Sass file from the module/variable list and creates foundation.css and foundation.min.css
gulp.task('customizer:sass', ['customizer:loadConfig'], function() {
var sassFile = customizer.sass(CUSTOMIZER_CONFIG, MODULE_LIST, VARIABLE_LIST);
.pipe(gulp.dest('.customizer/css'));
});
+// Creates a Foundation JavaScript file from the module list, and also copies dependencies (jQuery, what-input)
gulp.task('customizer:javascript', ['customizer:loadConfig'], function() {
var jsPaths = customizer.js(CUSTOMIZER_CONFIG, MODULE_LIST);
.pipe(gulp.dest('.customizer/js/vendor'));
});
+// Copies the boilerplate index.html to the custom download folder
gulp.task('customizer:html', ['customizer:loadConfig'], function() {
return gulp.src('customizer/index.html')
.pipe(gulp.dest('.customizer'));
});
+// Creates a custom build by:
+// - Generating a CSS file
+// - Generating a JS file
+// - Copying the index.html file
+// - Creating a blank app.css file
+// - Creating an app.js file with Foundation initialization code
gulp.task('customizer', ['customizer:sass', 'customizer:javascript', 'customizer:html'], function(done) {
touch('.customizer/css/app.css');
touch('.customizer/js/app.js');