UNPKG

react-middleware

Version:

Connect middleware for serving React components from a standard folder structure.

59 lines (48 loc) 1.97 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _ramda = require('ramda'); var _ramda2 = _interopRequireDefault(_ramda); var _template = require('./template'); var _template2 = _interopRequireDefault(_template); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Returns the set of template files. * @param paths: The middleware folder paths object. */ exports.default = function (paths) { var template = function template(sourceDir, sourceFile, targetFolder) { sourceDir = _ramda2.default.is(String, sourceDir) ? sourceDir + '/' : ''; var sourcePath = '../templates/' + sourceDir + sourceFile; var targetPath = targetFolder + '/' + sourceFile; return new _template2.default(sourcePath, targetPath); }; var templates = { routes: template(null, 'routes.js', paths.base), html: template('Html', 'Html.jsx', paths.layouts + '/Html'), htmlCss: template('Html', 'Html.styl', paths.layouts + '/Html'), home: template('Home', 'Home.jsx', paths.pages + '/Home'), homeCss: template('Home', 'Home.styl', paths.pages + '/Home'), homeEntry: template('Home', 'entry.js', paths.pages + '/Home'), normalizeCss: template('css', 'normalize.css', paths.css), globalMixins: template('css', 'global.mixin.styl', paths.css), scripts: template('scripts', 'index.js', paths.scripts), imageMoon1x: template('images', 'moon.jpg', paths.public + '/images'), imageMoon2x: template('images', 'moon@2x.jpg', paths.public + '/images'), /** * Creates all template files if they don't already exist. */ createSync: function createSync() { paths.createSync(); Object.keys(templates).forEach(function (key) { var file = templates[key]; if (file instanceof _template2.default) { file.copySync(); } }); } }; return templates; }; //# sourceMappingURL=templates.js.map