diff --git a/.eslintrc b/.eslintrc index 41f7a23..3d4f920 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,13 @@ "extends": "eslint:recommended", + "globals": { + // having some trouble getting eslint to recognize es6 features + "Promise": false, + "Set": false, + "Map": flase, + }, + // plugins let use use custom rules below "plugins": [ "babel", @@ -52,6 +59,7 @@ "comma-dangle": [2, "always-multiline"], "consistent-return": 0, "indent": [2, 2, {"SwitchCase": 1}], + "keyword-spacing": [2], "max-len": [1, 100, 2, {"ignoreComments": true}], "no-cond-assign": [2, "always"], "no-console": 0, @@ -78,12 +86,10 @@ "no-underscore-dangle": 0, "quotes": [2, "single"], "semi": [2, "always"], - "space-after-keywords": [2, "always"], "space-before-blocks": [2, "always"], "space-before-function-parentheses": [0, "never"], "space-in-brackets": [0, "never"], "space-in-parens": [2, "never"], - "space-return-throw-case": 1, "space-unary-ops": [1, { "words": true, "nonwords": false }], "strict": [2, "never"], "use-isnan": 2, @@ -103,7 +109,7 @@ "no-iterator": 2, "no-labels": 2, "no-lone-blocks": 2, - "no-loop-func": 2, + "no-loop-func": 0, "no-multi-spaces": 2, "no-multi-str": 2, "no-native-reassign": 2, diff --git a/bin/1.js b/bin/1.js new file mode 100644 index 0000000..a8c896a --- /dev/null +++ b/bin/1.js @@ -0,0 +1,18 @@ +exports.ids = [1]; +exports.modules = { + +/***/ 49: +/***/ function(module, exports) { + + function webpackEmptyContext(req) { + throw new Error("Cannot find module '" + req + "'."); + } + webpackEmptyContext.keys = function() { return []; }; + webpackEmptyContext.resolve = webpackEmptyContext; + module.exports = webpackEmptyContext; + webpackEmptyContext.id = 49; + + +/***/ } + +};; \ No newline at end of file diff --git a/bin/blueprints.js b/bin/blueprints.js new file mode 100755 index 0000000..6feb90d --- /dev/null +++ b/bin/blueprints.js @@ -0,0 +1,1325 @@ +#!/usr/bin/env node +var SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE = require; +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 48); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + var Generator = function Generator(nameOrNames, objectOrFunction) { + var names = nameOrNames; + if (!Array.isArray(names)) { + names = [names]; + } + + return { + names: names, + objectOrFunction: objectOrFunction + }; + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return Generator; }}); + + var applyGenerators = function applyGenerators(loaders, generator) { + generator.names.forEach(function (name) { + loaders[name] = generator.objectOrFunction; + }); + + return loaders; + }; + + var generatorLoader = function generatorLoader(thingKind, generators) { + var loaders = generators.reduce(function (prev, generator) { + return applyGenerators(_extends({}, prev), generator); + }, {}); + return function (loaderName) { + return tryToLoadGenerator(loaderName, loaders, thingKind); + }; + }; + /* harmony export */ Object.defineProperty(exports, "b", {configurable: false, enumerable: true, get: function() { return generatorLoader; }}); + + var tryToLoadGenerator = function tryToLoadGenerator(nameOrObject, lookupTable, thingKind) { + var parsed = parseNameOrObject(nameOrObject); + if (!parsed) { + return nameOrObject; + } + + var thing = lookupTable[parsed.name]; + if (!thing) { + throw new Error('Failed to resolve ' + nameOrObject + ' - ' + thingKind); + } + + if (typeof thing === 'function') { + return thing(parsed.options); + } + + return thing; + };/* unused harmony export tryToLoadGenerator */ + + var parseNameOrObject = function parseNameOrObject(nameOrObject) { + if (typeof nameOrObject === 'string') { + return { name: nameOrObject, options: {} }; + } + + if ((typeof nameOrObject === 'undefined' ? 'undefined' : _typeof(nameOrObject)) === 'object') { + var name = nameOrObject.generator; + if (typeof name === 'string') { + return { name: name, options: nameOrObject }; + } + } + }; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = require("webpack"); + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + module.exports = require("path"); + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + module.exports = require("extract-text-webpack-plugin"); + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + module.exports = require("colors"); + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + module.exports = require("lodash/object"); + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path__ = __webpack_require__(2); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path___default = __WEBPACK_IMPORTED_MODULE_0_path__ && __WEBPACK_IMPORTED_MODULE_0_path__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_path__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_path__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_path___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_path___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('simple', function (options) { + return { + path: /* harmony import */__WEBPACK_IMPORTED_MODULE_0_path___default.a.resolve(options.dest), + filename: options.name || '[name].js' + }; + }); + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path__ = __webpack_require__(2); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path___default = __WEBPACK_IMPORTED_MODULE_0_path__ && __WEBPACK_IMPORTED_MODULE_0_path__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_path__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_path__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_path___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_path___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Simple__ = __webpack_require__(8); + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + + + + var simple = /* harmony import */__WEBPACK_IMPORTED_MODULE_2__Simple__["a"].objectOrFunction; // its a function; + + var resolvePath = function resolvePath(strPath) { + return /* harmony import */__WEBPACK_IMPORTED_MODULE_0_path___default.a.resolve(strPath); + }; + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('modules', function (options) { + return _extends({}, simple(options), { + modules: (options.paths || []).map(resolvePath) + }); + }); + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()('simple', function (options) { + return { + extensions: options.extensions + }; + }); + +/***/ }, +/* 9 */ +/***/ function(module, exports) { + + module.exports = require("fs"); + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_node_notifier__ = __webpack_require__(50); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_node_notifier___default = __WEBPACK_IMPORTED_MODULE_1_node_notifier__ && __WEBPACK_IMPORTED_MODULE_1_node_notifier__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_1_node_notifier__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_1_node_notifier__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_1_node_notifier___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_1_node_notifier___default }); + + + + var build = function build(config, cb) { + var callback = cb || function () {}; + var run = function run(build) { + return executeBuild(build, callback); + }; + config.builds.forEach(run); + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return build; }}); + + var executeBuild = function executeBuild(build, cb) { + var compiler = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack___default.a.bind()(build.wepback); + if (build.watch) { + compiler.watch({}, function (err, stats) { + outputBuild(build.name)(err, stats); + cb(stats.toJson()); + }); + + return; + } + + compiler.run(function (err, stats) { + console.log(stats.toString({ + colors: !build.disableColors, + chunks: false, + version: false + })); + + cb(stats.toJson()); + }); + }; + + var formatAsset = function formatAsset(asset) { + var name = asset.name; + var size = asset.size; + var sizeStr = size + ' B'; + + if (size > 1000) { + sizeStr = Math.ceil(size / 1000) + ' kB'; + } + if (size > 1000000) { + sizeStr = Math.ceil(size / 1000000) + ' MB'; + } + + return name + ' [' + sizeStr + ']'; + }; + + var outputBuild = function outputBuild(type) { + return function (err, stats) { + if (err) { + console.log('error in build', err); + return; + } + + console.log(stats.toString({ + colors: true, + chunks: false, + version: false + })); + + var buildStats = stats.toJson(); + var errors = buildStats.errors; + + + if (errors && errors.length) { + /* harmony import */__WEBPACK_IMPORTED_MODULE_1_node_notifier___default.a.notify({ + title: type + ' - ERROR!', + message: 'Check the console for errors' + }); + return; + } + + /* harmony import */__WEBPACK_IMPORTED_MODULE_1_node_notifier___default.a.notify({ + title: type + ' - Build complete', + message: buildStats.assets.map(formatAsset).join('\n') + }); + }; + }; + +/***/ }, +/* 11 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony default export */ exports["a"] = { + name: 'Test', + webpack: { + devtool: 'source-map', + output: { + path: './.test', + filename: '[name]' + }, + resolve: { + generator: 'npm-and-modules', + paths: ['src', 'lib'], + extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + }, + loaders: ['esnextreact', 'json', 'ignore-styles'], + plugins: ['extract-css', 'abort-if-errors'], + externals: { + generator: 'node-modules', + additional: ['@r/platform/createTest'] + } + } + }; + +/***/ }, +/* 12 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Client__ = __webpack_require__(19); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__ProductionClient__ = __webpack_require__(20); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Server__ = __webpack_require__(22); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__ProductionServer__ = __webpack_require__(21); + + + + + + var getBuild = function getBuild(production, debugConfig, productionConfig) { + return production ? productionConfig : debugConfig; + }; + + var getClientConfig = function getClientConfig(production) { + return getBuild(production, /* harmony import */__WEBPACK_IMPORTED_MODULE_0__Client__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_1__ProductionClient__["a"]); + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getClientConfig; }}); + + var getServerConfig = function getServerConfig(production) { + return getBuild(production, /* harmony import */__WEBPACK_IMPORTED_MODULE_2__Server__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_3__ProductionServer__["a"]); + }; + /* harmony export */ Object.defineProperty(exports, "b", {configurable: false, enumerable: true, get: function() { return getServerConfig; }}); + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_colors__ = __webpack_require__(4); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_colors___default = __WEBPACK_IMPORTED_MODULE_0_colors__ && __WEBPACK_IMPORTED_MODULE_0_colors__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_colors__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_colors__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_colors___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_colors___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__getTestFiles__ = __webpack_require__(47); + + + + var magenta = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_colors___default.a.magenta; + + + var getWebpackEntryForTest = function getWebpackEntryForTest(dir) { + console.log(magenta('Searching for tests in ' + process.cwd())); + + var files = /* harmony import */__WEBPACK_IMPORTED_MODULE_1__getTestFiles__["a"].bind()(dir, '.test.'); + console.log(magenta('Found ' + files.length + ' test' + (files.length ? 's' : ''))); + + return files.reduce(function (prev, cur) { + var moduleName = cur.path.split('.test')[0].split('./')[1] + '.compiledtest'; + prev[moduleName] = cur.path; + return prev; + }, {}); + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getWebpackEntryForTest; }}); + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_object__ = __webpack_require__(5); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_object___default = __WEBPACK_IMPORTED_MODULE_0_lodash_object__ && __WEBPACK_IMPORTED_MODULE_0_lodash_object__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_lodash_object__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_lodash_object__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_lodash_object___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_lodash_object___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators_loaders__ = __webpack_require__(31); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_lib_generators_plugins__ = __webpack_require__(42); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_lib_generators_output__ = __webpack_require__(33); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_lib_generators_resolver__ = __webpack_require__(46); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_lib_generators_entry__ = __webpack_require__(23); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_lib_generators_postcss__ = __webpack_require__(44); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lib_generators_externals__ = __webpack_require__(24); + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + + + + + + + + + + + // ShortBuild is an object that looks like { + // name: String, + // watch: Bool, + // webpack: Object, shorthand webpack config + //} + + var makeBuild = function makeBuild(shortBuild) { + return _extends({}, shortBuild, { + wepback: parseWebpackConfig(shortBuild.webpack, shortBuild.name) + }); + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return makeBuild; }}); + + var mapNullable = function mapNullable(arrayOrNull, fn) { + return (arrayOrNull || []).map(fn); + }; + + var parseWebpackConfig = function parseWebpackConfig(shortHandConfig, buildName) { + var webpackConfig = { + entry: /* harmony import */__WEBPACK_IMPORTED_MODULE_5_lib_generators_entry__["a"].bind()(shortHandConfig.entry, buildName), + output: /* harmony import */__WEBPACK_IMPORTED_MODULE_3_lib_generators_output__["a"].bind()(shortHandConfig.output), + module: { + loaders: mapNullable(shortHandConfig.loaders, /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators_loaders__["a"]) + }, + plugins: mapNullable(shortHandConfig.plugins, /* harmony import */__WEBPACK_IMPORTED_MODULE_2_lib_generators_plugins__["a"]), + resolve: /* harmony import */__WEBPACK_IMPORTED_MODULE_4_lib_generators_resolver__["a"].bind()(shortHandConfig.resolve), + postcss: mapNullable(shortHandConfig.postcss, /* harmony import */__WEBPACK_IMPORTED_MODULE_6_lib_generators_postcss__["a"]), + externals: /* harmony import */__WEBPACK_IMPORTED_MODULE_7_lib_generators_externals__["a"].bind()(shortHandConfig.externals) + }; + + return _extends({}, webpackConfig, /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lodash_object__["omit"].bind()(shortHandConfig, Object.keys(webpackConfig).concat('loaders'))); + }; + +/***/ }, +/* 15 */ +/***/ function(module, exports) { + + module.exports = require("debug"); + +/***/ }, +/* 16 */ +/***/ function(module, exports) { + + module.exports = require("mocha"); + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + module.exports = require("rimraf"); + +/***/ }, +/* 18 */ +/***/ function(module, exports) { + + module.exports = require("yargs"); + +/***/ }, +/* 19 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony default export */ exports["a"] = { + name: 'Client', + webpack: { + devtool: 'source-map', + entry: './src/Client.js', + output: { + generator: 'simple', + dest: './bin' + }, + resolve: { + generator: 'npm-and-modules', + paths: ['src', 'lib'], + extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + }, + loaders: ['esnextreact', 'json', 'css', 'less'], + plugins: ['extract-css', 'abort-if-errors', { + generator: 'set-node-env', + env: 'client' + }] + } + }; + +/***/ }, +/* 20 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony default export */ exports["a"] = { + name: 'ProductionClient', + webpack: { + devtool: 'source-map', + entry: './src/Client.js', + output: { + generator: 'simple', + dest: './bin' + }, + resolve: { + generator: 'npm-and-modules', + paths: ['src', 'lib'], + extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + }, + loaders: ['esnextreact', 'json', 'css', 'less'], + plugins: ['extract-css', { + generator: 'set-node-env', + env: 'client' + }, 'production-loaders', 'minify-and-treeshake', 'abort-if-errors'] + } + }; + +/***/ }, +/* 21 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony default export */ exports["a"] = { + name: 'ProductionServer', + webpack: { + devtool: 'source-map', + entry: './src/Server.js', + output: { + generator: 'simple', + dest: './bin' + }, + externals: { + generator: 'node-modules', + additional: ['os'] + }, + resolve: { + generator: 'npm-and-modules', + paths: ['src', 'lib'], + extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + }, + loaders: ['esnextreact', 'json', 'ignore-styles'], + plugins: ['production-loaders', 'minify-and-treeshake', 'abort-if-errors', 'node-load-sourcemaps'], + node: { + Buffer: false, + process: false, + global: false, + __filename: true, + __dirname: true + } + } + }; + +/***/ }, +/* 22 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony default export */ exports["a"] = { + name: 'Server', + webpack: { + devtool: 'source-map', + entry: './src/Server.js', + output: { + generator: 'simple', + dest: './bin' + }, + externals: { + generator: 'node-modules', + additional: ['os'] + }, + resolve: { + generator: 'npm-and-modules', + paths: ['src', 'lib'], + extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + }, + loaders: ['esnextreact', 'json', 'ignore-styles'], + plugins: ['abort-if-errors', 'node-load-sourcemaps'], + node: { + Buffer: false, + process: false, + global: false, + __filename: true, + __dirname: true, + os: false + } + } + }; + +/***/ }, +/* 23 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path__ = __webpack_require__(2); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_path___default = __WEBPACK_IMPORTED_MODULE_0_path__ && __WEBPACK_IMPORTED_MODULE_0_path__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_path__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_path__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_path___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_path___default }); + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + + + + var getEntry = function getEntry(pathOrObject, buildName) { + // for now takes the path to the file, and the build name and makes + // the entry point object. in the future we can do things like auto traverers + // the module paths you're resolving and generate tree-shaking-less umd ready builds + // but if everything internal is using the build project its a little pointless + // return tryToLoadGenerator(entryName, entryGenerators, 'entry'); + if ((typeof pathOrObject === 'undefined' ? 'undefined' : _typeof(pathOrObject)) === 'object') { + return pathOrObject; + } + + var entryConfig = {}; + entryConfig[buildName] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_path___default.a.resolve(pathOrObject); + return entryConfig; + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getEntry; }}); + +/***/ }, +/* 24 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__loadNodeModules__ = __webpack_require__(25); + var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; + + + + var loaderName = 'node-modules'; + + var getExternals = function getExternals(externals) { + if (typeof externals === 'string') { + if (externals === loaderName) { + return /* harmony import */__WEBPACK_IMPORTED_MODULE_0__loadNodeModules__["a"].bind()(); + } + + throw new Error('Invalid externals loader name, did you mean: ' + loaderName + ' ?'); + } + + if ((typeof externals === 'undefined' ? 'undefined' : _typeof(externals)) === 'object') { + if (externals.generator === loaderName) { + return /* harmony import */__WEBPACK_IMPORTED_MODULE_0__loadNodeModules__["a"].bind()(externals.additional); + } + + return externals; + } + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getExternals; }}); + +/***/ }, +/* 25 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs__ = __webpack_require__(9); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs___default = __WEBPACK_IMPORTED_MODULE_0_fs__ && __WEBPACK_IMPORTED_MODULE_0_fs__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_fs__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_fs__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_fs___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_fs___default }); + + + var prependCommonjs = function prependCommonjs(modules, name) { + modules[name] = 'commonjs ' + name; + return modules; + }; + + var lodashSubmodules = ['array', 'collection', 'date', 'function', 'lang', 'math', 'number', 'object', 'seq', 'string', 'util', 'properties', 'methods'].map(function (name) { + return 'lodash/' + name; + }); + + var loadNodeModules = function loadNodeModules(additional) { + var nodeModules = {}; + + /* harmony import */__WEBPACK_IMPORTED_MODULE_0_fs___default.a.readdirSync('node_modules').filter(function (x) { + return ['.bin'].indexOf(x) === -1; + }).reduce(prependCommonjs, nodeModules); + + if (additional) { + additional.reduce(prependCommonjs, nodeModules); + } + + if (nodeModules.lodash) { + lodashSubmodules.reduce(prependCommonjs, nodeModules); + } + + return nodeModules; + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return loadNodeModules; }}); + +/***/ }, +/* 26 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ = __webpack_require__(3); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default = __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ && __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('css', { + test: /\.css$/, + loader: /* harmony import */__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default.a.extract('style-loader', 'css-loader!postcss-loader') + }); + +/***/ }, +/* 27 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()(['esnextreact', 'ESNextReact'], { + test: /\.es6\.js$|\.js$|\.jsx$/, + exclude: /node_modules/, + loader: 'babel', + query: { + presets: ['es2015-native-modules', 'stage-2', 'react'], + plugins: ['transform-class-properties', 'transform-react-constant-elements', 'transform-react-inline-elements', 'lodash'] + } + }); + +/***/ }, +/* 28 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()('ignore-styles', { + test: /\.css$|\.less$/, + loader: 'ignore-loader' + }); + +/***/ }, +/* 29 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()('json', { + test: /\.json$/, + loader: 'json-loader' + }); + +/***/ }, +/* 30 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ = __webpack_require__(3); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default = __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ && __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('less', { + test: /\.less$/, + loader: /* harmony import */__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default.a.extract('style-loader', 'css-loader!postcss-loader!less-loader') + }); + +/***/ }, +/* 31 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CSS__ = __webpack_require__(26); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__ESNextReact__ = __webpack_require__(27); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__IgnoreStyles__ = __webpack_require__(28); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__JSON__ = __webpack_require__(29); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Less__ = __webpack_require__(30); + + + + + + + + + var getLoader = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["b"].bind()('loader', [/* harmony import */__WEBPACK_IMPORTED_MODULE_1__CSS__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_2__ESNextReact__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_3__IgnoreStyles__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_4__JSON__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_5__Less__["a"]]); + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getLoader; }}); + +/***/ }, +/* 32 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Simple__ = __webpack_require__(6); + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + + + var simple = /* harmony import */__WEBPACK_IMPORTED_MODULE_1__Simple__["a"].objectOrFunction; // is a function + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()(['this', 'commonjs', 'commonjs2', 'amd', 'umd'], function (options) { + return _extends({}, simple(options), { + library: options.libraryName || '[name].js', + // use options.generator to know the name we've been passed, which will be one of the above ^ + libraryTarget: options.target || options.generator || 'var' + }); + }); + +/***/ }, +/* 33 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Library__ = __webpack_require__(32); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Simple__ = __webpack_require__(6); + + + + + + var getOutput = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["b"].bind()('output', [/* harmony import */__WEBPACK_IMPORTED_MODULE_1__Library__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_2__Simple__["a"]]); + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getOutput; }}); + +/***/ }, +/* 34 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('abort-if-errors', function () { + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["NoErrorsPlugin"](); + }); + +/***/ }, +/* 35 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + var CommonsChunkPlugin = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["optimize"].CommonsChunkPlugin; + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('bundle-common', function () { + return new CommonsChunkPlugin({ + name: 'vendor', + minChunks: Infinity, + filename: 'vendor.bundle.js' + }); + }); + +/***/ }, +/* 36 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('production-loaders', function () { + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["LoaderOptionsPlugin"]({ + minimize: true, + debug: false + }); + }); + +/***/ }, +/* 37 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ = __webpack_require__(3); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default = __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__ && __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('extract-css', function () { + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_extract_text_webpack_plugin___default.a('[name].css'); + }); + +/***/ }, +/* 38 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + var UglifyJsPlugin = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["optimize"].UglifyJsPlugin; + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('minify-and-treeshake', function () { + return new UglifyJsPlugin({ + compress: { warnings: false }, + output: { comments: false }, + sourceMap: true + }); + }); + +/***/ }, +/* 39 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('node-executable', function () { + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["BannerPlugin"]({ + banner: '#!/usr/bin/env node', + raw: true, + entryOnly: true + }); + }); + +/***/ }, +/* 40 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('node-load-sourcemaps', function () { + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["BannerPlugin"]({ + banner: 'require("source-map-support").install();', + raw: true, + entryOnly: false + }); + }); + +/***/ }, +/* 41 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_webpack___default = __WEBPACK_IMPORTED_MODULE_0_webpack__ && __WEBPACK_IMPORTED_MODULE_0_webpack__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_webpack__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_webpack___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_webpack___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_lib_generators__ = __webpack_require__(0); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_lib_generators__["a"].bind()('set-node-env', function (options) { + var nodeEnv = "production" || 'production'; + var env = "server" || 'server'; + + return new /* harmony import */__WEBPACK_IMPORTED_MODULE_0_webpack__["DefinePlugin"]({ + 'process.env': { + NODE_ENV: JSON.stringify(options.nodeEnv || nodeEnv), + ENV: JSON.stringify(options.env || env) + } + }); + }); + +/***/ }, +/* 42 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__AbortIfErrors__ = __webpack_require__(34); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BundleCommonChunks__ = __webpack_require__(35); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__EnableProductionLoaders__ = __webpack_require__(36); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__ExtractCSS__ = __webpack_require__(37); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__MinifyAndTreeShake__ = __webpack_require__(38); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__NodeExecutable__ = __webpack_require__(39); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__NodeLoadSourceMaps__ = __webpack_require__(40); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__SetNodeEnvironment__ = __webpack_require__(41); + + + + + + + + + + + + var getPlugin = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["b"].bind()('plugin', [/* harmony import */__WEBPACK_IMPORTED_MODULE_1__AbortIfErrors__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_2__BundleCommonChunks__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_3__EnableProductionLoaders__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_4__ExtractCSS__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_5__MinifyAndTreeShake__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_6__NodeExecutable__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_7__NodeLoadSourceMaps__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_8__SetNodeEnvironment__["a"]]); + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getPlugin; }}); + +/***/ }, +/* 43 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_autoprefixer__ = __webpack_require__(49); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_autoprefixer___default = __WEBPACK_IMPORTED_MODULE_1_autoprefixer__ && __WEBPACK_IMPORTED_MODULE_1_autoprefixer__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_1_autoprefixer__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_1_autoprefixer__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_1_autoprefixer___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_1_autoprefixer___default }); + + + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()('autoprefixer', function (options) { + return /* harmony import */__WEBPACK_IMPORTED_MODULE_1_autoprefixer___default.a.bind()({ + browsers: ['last ' + (options.numVersions || 2) + ' versions'] + }); + }); + +/***/ }, +/* 44 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Autoprefixer__ = __webpack_require__(43); + + + + var getPostCSS = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["b"].bind()('postcsshooks', [/* harmony import */__WEBPACK_IMPORTED_MODULE_1__Autoprefixer__["a"]]); + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getPostCSS; }}); + +/***/ }, +/* 45 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Modules__ = __webpack_require__(7); + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + + + var modules = /* harmony import */__WEBPACK_IMPORTED_MODULE_1__Modules__["a"].objectOrFunction; // its a function; + + /* harmony default export */ exports["a"] = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["a"].bind()('npm-and-modules', function (options) { + var result = modules(options); + return _extends({}, result, { + modules: result.modules.concat('node_modules') + }); + }); + +/***/ }, +/* 46 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lib_generators__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Modules__ = __webpack_require__(7); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__NPMAndModules__ = __webpack_require__(45); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Simple__ = __webpack_require__(8); + + + + + + + var getResolver = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lib_generators__["b"].bind()('resolver', [/* harmony import */__WEBPACK_IMPORTED_MODULE_1__Modules__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_2__NPMAndModules__["a"], /* harmony import */__WEBPACK_IMPORTED_MODULE_3__Simple__["a"]]); + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getResolver; }}); + +/***/ }, +/* 47 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs__ = __webpack_require__(9); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_fs___default = __WEBPACK_IMPORTED_MODULE_0_fs__ && __WEBPACK_IMPORTED_MODULE_0_fs__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_fs__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_fs__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_fs___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_fs___default }); + + + var getTestFiles = function getTestFiles(dir, ext) { + if (dir.indexOf('node_modules') > -1) { + return; + } + if (dir.indexOf('.git') > -1) { + return; + } + + var files = []; + try { + files = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_fs___default.a.readdirSync(dir); + } catch (e) { + files = []; + } + + return files.map(function (file) { + var path = '' + dir + file; + + try { + var stats = /* harmony import */__WEBPACK_IMPORTED_MODULE_0_fs___default.a.statSync(path); + if (stats.isDirectory()) { + return getTestFiles(path + '/' + ext); + } + if (file.indexOf(ext) > -1) { + return { file: file, path: path }; + } + return null; + } catch (e) { + return null; + } + }).filter(function (x) { + return x; + }).reduce(function (prev, cur) { + if (Array.isArray(cur)) { + return prev.concat(cur); + } + + return prev.concat([cur]); + }, []); + }; + /* harmony export */ Object.defineProperty(exports, "a", {configurable: false, enumerable: true, get: function() { return getTestFiles; }}); + +/***/ }, +/* 48 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_object__ = __webpack_require__(5); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_lodash_object___default = __WEBPACK_IMPORTED_MODULE_0_lodash_object__ && __WEBPACK_IMPORTED_MODULE_0_lodash_object__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_lodash_object__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_lodash_object__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_lodash_object___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_lodash_object___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_colors__ = __webpack_require__(4); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_colors___default = __WEBPACK_IMPORTED_MODULE_1_colors__ && __WEBPACK_IMPORTED_MODULE_1_colors__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_1_colors__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_1_colors__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_1_colors___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_1_colors___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_debug__ = __webpack_require__(15); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_debug___default = __WEBPACK_IMPORTED_MODULE_2_debug__ && __WEBPACK_IMPORTED_MODULE_2_debug__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_2_debug__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_2_debug__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_2_debug___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_2_debug___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_mocha__ = __webpack_require__(16); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_mocha___default = __WEBPACK_IMPORTED_MODULE_3_mocha__ && __WEBPACK_IMPORTED_MODULE_3_mocha__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_3_mocha__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_3_mocha__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_3_mocha___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_3_mocha___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_path__ = __webpack_require__(2); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_path___default = __WEBPACK_IMPORTED_MODULE_4_path__ && __WEBPACK_IMPORTED_MODULE_4_path__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_4_path__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_4_path__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_4_path___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_4_path___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_rimraf__ = __webpack_require__(17); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_rimraf___default = __WEBPACK_IMPORTED_MODULE_5_rimraf__ && __WEBPACK_IMPORTED_MODULE_5_rimraf__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_5_rimraf__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_5_rimraf__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_5_rimraf___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_5_rimraf___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_yargs__ = __webpack_require__(18); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_yargs___default = __WEBPACK_IMPORTED_MODULE_6_yargs__ && __WEBPACK_IMPORTED_MODULE_6_yargs__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_6_yargs__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_6_yargs__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_6_yargs___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_6_yargs___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_lib_build__ = __webpack_require__(10); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_lib_makeBuild__ = __webpack_require__(14); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_lib_configs__ = __webpack_require__(12); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_lib_configs_Testing__ = __webpack_require__(11); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_lib_getWebpackEntryForTest__ = __webpack_require__(13); + var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + + + + + + + + + + + + + + + + var debug = /* harmony import */__WEBPACK_IMPORTED_MODULE_2_debug___default.a.bind()('blueprints'); + + var blue = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_colors___default.a.blue; + var white = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_colors___default.a.white; + var magenta = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_colors___default.a.magenta; + var red = /* harmony import */__WEBPACK_IMPORTED_MODULE_1_colors___default.a.red; + + /* eslint-disable max-len */ + + var argv = /* harmony import */__WEBPACK_IMPORTED_MODULE_6_yargs___default.a.alias('b', 'blueprintsPath').describe('b', 'path to a raw-config via a node file with moduel.exports = config').default('b', './blueprints.config.js').alias('p', 'production').describe('p', 'enable production settings for the default build cofings').default('p', false).alias('c', 'client').describe('c', 'use the default client build, assumes you have an entry point to a client at ~/lib/client.[some es6.js or .js or .jsx]').default('c', false).alias('s', 'server').describe('s', 'use the default server build, assumes you have an entry point to a server at ~/lib/server[some es6.js or .js or .jsx]').default('s', false).alias('a', 'clientAndServer').describe('a', '[DEFAULT=true] use both a client and a server build. checks if you have an extend build and applies it.').default('a', true).alias('w', 'watch').describe('w', '[DEFAULT=false] force watching of all builds').default('w', false).alias('i', 'ignoreBlueprints').describe('ignore the blueprints.config.js file in the current directory and use defaults').default('i', false).alias('t', 'runTest').describe('search for test files and run them').default('t', false).argv; + /* eslint-enable */ + + var loadBuildsFromPath = function loadBuildsFromPath(filePath) { + try { + console.log(blue('..loading config ' + filePath)); + /* eslint-disable no-undef */ + // SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE is our hook outside of + // webpack's normal requires -- webpack normally resolves requires at compile time + // and turns require statments that are dynamic, or that it can't resolve, into error throwing + // thunks. I tried doing this with require.ensure, and webpack turned that into + // error throwing thunks as well, so this seems like the 'cleanest' solution. + var builds = SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE(/* harmony import */__WEBPACK_IMPORTED_MODULE_4_path___default.a.resolve(filePath)); + /* eslint-enable */ + if (!Array.isArray(builds)) { + if (builds.extensions === true) { + return { extensions: /* harmony import */__WEBPACK_IMPORTED_MODULE_0_lodash_object__["omit"].bind()(builds, 'extensions') }; + } + builds = [builds]; + } + + return { builds: builds }; + } catch (e) { + debug(e); + return {}; + } + }; + + var loadDefaultConfigs = function loadDefaultConfigs(options) { + console.log(blue('..using default configs')); + if (options.runTest) { + console.log(magenta('..Setting up tests:')); + return [_extends({}, /* harmony import */__WEBPACK_IMPORTED_MODULE_10_lib_configs_Testing__["a"], { + webpack: { + entry: /* harmony import */__WEBPACK_IMPORTED_MODULE_11_lib_getWebpackEntryForTest__["a"].bind()('./') + } + })]; + } else if (options.client) { + console.log(blue('..client')); + return [/* harmony import */__WEBPACK_IMPORTED_MODULE_9_lib_configs__["a"].bind()(options.production)]; + } else if (options.server) { + console.log(blue('..server')); + return [/* harmony import */__WEBPACK_IMPORTED_MODULE_9_lib_configs__["b"].bind()(options.production)]; + } else if (options.clientAndServer) { + console.log(blue('..both')); + return [/* harmony import */__WEBPACK_IMPORTED_MODULE_9_lib_configs__["a"].bind()(options.production), /* harmony import */__WEBPACK_IMPORTED_MODULE_9_lib_configs__["b"].bind()(options.production)]; + } + + return []; + }; + + var makeConfig = function makeConfig(options) { + console.log(blue('[Blueprints] reading from ' + options.blueprintsPath)); + console.log(blue('[cwd] ' + process.cwd())); + + var builds = []; + var extensions = {}; + + if (options.blueprintsPath && !options.ignoreBlueprints) { + var blueprints = loadBuildsFromPath(options.blueprintsPath); + if (blueprints.extensions) { + extensions = blueprints.extensions; + } else if (blueprints.builds && blueprints.builds.length) { + builds = blueprints.builds; + } + } + + if (!builds.length) { + loadDefaultConfigs(); + } + + if (options.watch) { + extensions.watch = true; + } + + return { + builds: applyExtensions(builds, extensions).map(/* harmony import */__WEBPACK_IMPORTED_MODULE_8_lib_makeBuild__["a"]) + }; + }; + + var applyExtensions = function applyExtensions(builds, extensions) { + var ext = extensions || {}; + if (Object.keys(ext).length > 0) { + console.log(blue('[extensions]') + ': ' + white(JSON.stringify(extensions, null, 2))); + } + + return builds.map(function (build) { + return _extends({}, build, ext); + }); + }; + + /* harmony import */__WEBPACK_IMPORTED_MODULE_7_lib_build__["a"].bind()(makeConfig(argv), function (stats) { + if (stats.errors && stats.errors.length > 0 && !argv.watch) { + console.log(red('ERROR IN BUILD. Aborting.')); + + process.exit(1); + } + + if (argv.runTest) { + (function () { + console.log(magenta('\n ******************************' + '\n * RUNNING TESTS *' + '\n ******************************')); + + var mochaInstance = new /* harmony import */__WEBPACK_IMPORTED_MODULE_3_mocha___default.a(); + stats.assets.forEach(function (asset) { + mochaInstance.addFile('./.test/' + asset.name); + }); + + mochaInstance.run().on('end', function () { + /* harmony import */__WEBPACK_IMPORTED_MODULE_5_rimraf___default.a.bind()('./.test/', function () {}); + }); + })(); + } + }); + +/***/ }, +/* 49 */ +/***/ function(module, exports) { + + module.exports = require("autoprefixer"); + +/***/ }, +/* 50 */ +/***/ function(module, exports) { + + module.exports = require("node-notifier"); + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/bin/buildBlueprints.js b/bin/buildBlueprints.js deleted file mode 100755 index a1b94b9..0000000 --- a/bin/buildBlueprints.js +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env node -var _ = require('lodash'); -var fs = require('fs'); -var path = require('path'); -var debug = require('debug')('blueprints'); -var Mocha = require('mocha'); -var colors = require('colors'); -var rimraf = require('rimraf'); - -var build = require('../lib/build'); -var makeBuild = require('../lib/makeBuild').makeBuild; -var configs = require('../lib/configs'); -var getWebpackEntryForTest = require('../lib/getWebpackEntryForTest'); - -var argv = require('yargs') - .alias('b', 'blueprintsPath') - .describe('b', 'path to a raw-config via a node file with moduel.exports = config') - .default('b', './blueprints.config.js') - .alias('p', 'production') - .describe('p', 'enable production settings for the default build cofings') - .default('p', false) - .alias('c', 'client') - .describe('c', 'use the default client build, assumes you have an entry point to a client at ~/lib/client.[some es6.js or .js or .jsx]') - .default('c', false) - .alias('s', 'server') - .describe('s', 'use the default server build, assumes you have an entry point to a server at ~/lib/server[some es6.js or .js or .jsx]') - .default('s', false) - .alias('a', 'clientAndServer') - .describe('a', '[DEFAULT=true] use both a client and a server build. checks if you have an extend build and applies it.') - .default('a', true) - .alias('w', 'watch') - .describe('w', '[DEFAULT=false] force watching of all builds') - .default('w', false) - .alias('i', 'ignoreBlueprints') - .describe('ignore the blueprints.config.js file in the current directory and use defaults') - .default('i', false) - .alias('t', 'runTest') - .describe('search for test files and run them') - .default('t', false) - .argv; - -console.log('...Reading Blueprints', argv.blueprintsPath); -console.log('...cwd', process.cwd()); - -function loadBuildsFromPath(configPath) { - try { - console.log('...loading bluerprints from', configPath) - var builds = require(path.resolve(configPath)); - if (!Array.isArray(builds)) { - if (builds.extensions === true) { - return { extensions: _.omit(builds, 'extensions') }; - } - builds = [builds]; - } - - return { builds } - } catch (e) { - debug(e); - return {}; - } -} - -function applyExtensions(builds, extensions) { - var ext = extensions || {}; - console.log('...applying extensions', extensions); - return builds.map(function(build) { return _.merge(build, ext ); }); -} - -function makeConfig(builds, extensions) { - return { builds: applyExtensions(builds, extensions).map(makeBuild) }; -} - -var builds = []; -var extensions = {}; - -if (argv.blueprintsPath && !argv.ignoreBlueprints) { - var blueprints = loadBuildsFromPath(argv.blueprintsPath); - if (blueprints.extensions) { - extensions = blueprints.extensions; - } else if (blueprints.builds && blueprints.builds.length) { - builds = blueprints.builds; - } -} - -function loadDefaultConfigs() { - console.log('...using default configs'); - if (argv.runTest) { - console.log('...Setting up tests:'); - builds = [ configs.DefaultTestingConfig ]; - builds[0].webpack.entry = getWebpackEntryForTest('./'); - } else if (argv.client) { - console.log('...client'); - builds = [ configs.getClientConfig(argv.production) ]; - } else if (argv.server) { - console.log('...server'); - builds = [ configs.getServerConfig(argv.production) ]; - } else if (argv.clientAndServer) { - console.log('...both'); - builds = [ - configs.getClientConfig(argv.production), - configs.getServerConfig(argv.production), - ]; - } -} - -if (!builds.length) { - loadDefaultConfigs(); -} - -if (argv.watch) { - extensions.watch = true; -} - -build(makeConfig(builds, extensions), function(stats) { - if (stats.errors && stats.errors.length > 0 && !argv.watch) { - console.log(colors.red( - 'ERROR IN BUILD. Aborting.' - )); - - process.exit(1); - } - - if (argv.runTest) { - console.log(colors.magenta( - '\n ******************************' + - '\n * RUNNING TESTS *' + - '\n ******************************' - )); - - var m = new Mocha(); - stats.assets.forEach(function(asset) { - var path = './.test/' + asset.name; - m.addFile(path); - }); - m.run() - .on('end', function() { - rimraf('./.test/', function() {}); - }); - } -}); diff --git a/bin/buildWebfonts.js b/bin/buildWebfonts.js deleted file mode 100755 index e6e0a48..0000000 --- a/bin/buildWebfonts.js +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env node -var glob = require('glob'); -var path = require('path'); -var webfontsGenerator = require('webfonts-generator'); - -var SRC = path.resolve('./assets/svg/*.svg'); - -glob(SRC, function(error, files) { - console.log('generating font from:\n', files); - - webfontsGenerator({ - files: files, - dest: path.resolve('./assets/fonts'), - fontName: 'rfont', - css: true, - cssDest: path.resolve('./assets/fonts/rfont.css'), - cssFontsUrl: '/fonts', - html: true, - types: ['svg', 'ttf', 'woff', 'eot'], - normalize: true, - }) -}); diff --git a/bin/webfonts.js b/bin/webfonts.js new file mode 100755 index 0000000..e03f34b --- /dev/null +++ b/bin/webfonts.js @@ -0,0 +1,115 @@ +#!/usr/bin/env node +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.l = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 4); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports) { + + module.exports = require("colors"); + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = require("glob"); + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + module.exports = require("path"); + +/***/ }, +/* 3 */ +/***/ function(module, exports) { + + module.exports = require("webfonts-generator"); + +/***/ }, +/* 4 */ +/***/ function(module, exports, __webpack_require__) { + + "use strict"; + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_colors__ = __webpack_require__(0); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_colors___default = __WEBPACK_IMPORTED_MODULE_0_colors__ && __WEBPACK_IMPORTED_MODULE_0_colors__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_0_colors__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_0_colors__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_0_colors___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_0_colors___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_glob__ = __webpack_require__(1); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_glob___default = __WEBPACK_IMPORTED_MODULE_1_glob__ && __WEBPACK_IMPORTED_MODULE_1_glob__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_1_glob__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_1_glob__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_1_glob___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_1_glob___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_path__ = __webpack_require__(2); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_path___default = __WEBPACK_IMPORTED_MODULE_2_path__ && __WEBPACK_IMPORTED_MODULE_2_path__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_2_path__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_2_path__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_2_path___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_2_path___default }); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_webfonts_generator__ = __webpack_require__(3); + /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_webfonts_generator___default = __WEBPACK_IMPORTED_MODULE_3_webfonts_generator__ && __WEBPACK_IMPORTED_MODULE_3_webfonts_generator__.__esModule ? function() { return __WEBPACK_IMPORTED_MODULE_3_webfonts_generator__['default'] } : function() { return __WEBPACK_IMPORTED_MODULE_3_webfonts_generator__; } + /* harmony import */ Object.defineProperty(__WEBPACK_IMPORTED_MODULE_3_webfonts_generator___default, 'a', { get: __WEBPACK_IMPORTED_MODULE_3_webfonts_generator___default }); + + + + + + var SRC = /* harmony import */__WEBPACK_IMPORTED_MODULE_2_path___default.a.resolve('./assets/svg/*.svg'); + + /* harmony import */__WEBPACK_IMPORTED_MODULE_1_glob___default.a.bind()(SRC, function (error, files) { + /* eslint-disable max-len */ + console.log(/* harmony import */__WEBPACK_IMPORTED_MODULE_0_colors___default.a.yellow('[Webfonts] generating from') + ' ' + /* harmony import */__WEBPACK_IMPORTED_MODULE_0_colors___default.a.white(JSON.stringify(files, null, 2))); + /* eslint-enable */ + + if (error) { + console.log(/* harmony import */__WEBPACK_IMPORTED_MODULE_0_colors___default.a.red('[Error]') + ' ' + /* harmony import */__WEBPACK_IMPORTED_MODULE_0_colors___default.a.white(JSON.stringify(error, null, 2))); + } + + /* harmony import */__WEBPACK_IMPORTED_MODULE_3_webfonts_generator___default.a.bind()({ + files: files, + dest: /* harmony import */__WEBPACK_IMPORTED_MODULE_2_path___default.a.resolve('./assets/fonts'), + fontName: 'rfont', + css: true, + cssDest: /* harmony import */__WEBPACK_IMPORTED_MODULE_2_path___default.a.resolve('./assets/fonts/rfont.css'), + cssFontsUrl: '/fonts', + html: true, + types: ['svg', 'ttf', 'woff', 'eot'], + normalize: true + }); + }); + +/***/ } +/******/ ]); \ No newline at end of file diff --git a/blueprints.config.js b/blueprints.config.js new file mode 100644 index 0000000..6347907 --- /dev/null +++ b/blueprints.config.js @@ -0,0 +1,84 @@ +/* eslint-disable */ +// It would be cool to start compiling blueprings configs so you could write +// ES6+ for your ES6+ but that might be getting excessive. +var webpack = require('webpack'); +var _ = require('lodash'); + +function makeConfig(name) { + var entry = {}; + entry[name] = './src/' + name + '.js'; + + return { + name: name, + webpack: { + entry, + output: { + generator: 'simple', + dest: './bin', + }, + resolve: { + generator: 'npm-and-modules', + paths: [ '' ], + extensions: ['', '.js', '.json'], + }, + loaders: [ + 'esnextreact', + 'json', + ], + plugins: [ + 'production-loaders', + 'set-node-env', + 'abort-if-errors', + 'node-executable', + // 'node-load-sourcemaps', + // 'minify-and-treeshake', + ], + externals: 'node-modules', + target: 'node', + node: { + path: false, + process: false, + __filename: false, + __dirname: false, + os: false, + global: false, + Buffer: false, + require: false, + }, + }, + }; +} + +function requireHookPlugin() { + return new webpack.BannerPlugin({ + banner: 'var SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE = require;', + raw: true, + entryOnly: true, + }); +} + +function makeBlueprintsConfig() { + var blueprintsConfig = makeConfig('blueprints'); + + // Blueprints is special because config files are written as node targeted javascript. + // To pull this off the blueprints compiled file needs a way to dynamicaly require files + // based on the arguments passed to it via CLI. Webpack normally resolves all require + // statements, and dynamic require's get turned into Errors (technically an automatic annonymous + // functions that throw errors). To get around this we use a banner plugin that defines a variable + // which is defined to be require. Banner plugins can run as raw, bypassing them compilation step which gets us around + // webpack's require re-writing. I tried doing this with require.ensure (which should work), + // but this also produced error throwing functions. + return _.merge( + {}, + blueprintsConfig, { + webpack: { + plugins: [ requireHookPlugin() ].concat(blueprintsConfig.webpack.plugins), + }, + } + ); +} + +module.exports = [ + makeBlueprintsConfig(), + makeConfig('webfonts'), +]; diff --git a/examples/client/src/Client.es6.js b/examples/client/src/Client.js similarity index 100% rename from examples/client/src/Client.es6.js rename to examples/client/src/Client.js diff --git a/lib/build.js b/lib/build.js index 83922e9..b117789 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,71 +1,70 @@ -/* eslint-disable */ +import webpack from 'webpack'; +import notifier from 'node-notifier'; -var webpack = require('webpack'); -var notifier = require('node-notifier'); -var _ = require('lodash'); -var fs = require('fs'); +export const build = (config, cb) => { + const callback = cb || (() => {}); + const run = build => executeBuild(build, callback); + config.builds.forEach(run); +}; -const nodeEnv = process.env.NODE_ENV || 'development'; - -module.exports = function(config, cb) { - if (!cb) { cb = function() {}; } - config.builds.forEach(function(build) { - exectuteBuild(build, cb); - }); -} - -function exectuteBuild(build, cb) { - var compiler = webpack(build.webpackConfig); +const executeBuild = (build, cb) => { + const compiler = webpack(build.wepback); if (build.watch) { - compiler.watch({}, function(err, stats) { - outputBuild(build.buildName)(err, stats); - cb(stats.toJson()); - }); - } else { - compiler.run(function(err, stats) { - console.log(stats.toString({ - colors: !build.disableColors, - chunks: false, - version: false, - })); + compiler.watch({}, (err, stats) => { + outputBuild(build.name)(err, stats); cb(stats.toJson()); }); + + return; } -} -function formatAsset(asset) { - var name = asset.name; - var size = asset.size; - var sizeStr = size + " B"; + compiler.run((err, stats) => { + console.log(stats.toString({ + colors: !build.disableColors, + chunks: false, + version: false, + })); + + cb(stats.toJson()); + }); +}; + +const formatAsset = asset => { + const name = asset.name; + const size = asset.size; + let sizeStr = `${size} B`; - if (size > 1000) sizeStr = Math.ceil(size / 1000) + " kB"; - if (size > 1000000) sizeStr = Math.ceil(size / 1000000) + " MB"; + if (size > 1000) { sizeStr = `${Math.ceil(size / 1000)} kB`; } + if (size > 1000000) { sizeStr = `${Math.ceil(size / 1000000)} MB`; } - return name + " [" + sizeStr + "]"; -} + return `${name} [${sizeStr}]`; +}; + +const outputBuild = type => (err, stats) => { + if (err) { + console.log('error in build', err); + return; + } -function outputBuild(type) { - return function(err, stats) { - if (!err) { - console.log(stats.toString({ - colors: true, - chunks: false, - version: false, - })); + console.log(stats.toString({ + colors: true, + chunks: false, + version: false, + })); - var s = stats.toJson(); + const buildStats = stats.toJson(); + const { errors } = buildStats; - if (s.errors && s.errors.length) { - notifier.notify({ - "title": type + " – ERROR!", - "message": "Check the console for errors", - }); - } else { - notifier.notify({ - "title": type + " – Build complete", - "message": s.assets.map(formatAsset).join("\n"), - }); - } - } + if (errors && errors.length) { + notifier.notify({ + title: `${type} - ERROR!`, + message: 'Check the console for errors', + }); + return; } -} + + notifier.notify({ + title: `${type} - Build complete`, + message: buildStats.assets.map(formatAsset).join('\n'), + }); +}; diff --git a/lib/configs/DefaultClientConfig.js b/lib/configs/Client.js similarity index 96% rename from lib/configs/DefaultClientConfig.js rename to lib/configs/Client.js index 4c8cadf..4fd69b8 100644 --- a/lib/configs/DefaultClientConfig.js +++ b/lib/configs/Client.js @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'Client', webpack: { devtool: 'source-map', diff --git a/lib/configs/DefaultProductionClientConfig.js b/lib/configs/ProductionClient.js similarity index 87% rename from lib/configs/DefaultProductionClientConfig.js rename to lib/configs/ProductionClient.js index 82f3d38..3165fc3 100644 --- a/lib/configs/DefaultProductionClientConfig.js +++ b/lib/configs/ProductionClient.js @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'ProductionClient', webpack: { devtool: 'source-map', @@ -10,7 +10,7 @@ module.exports = { resolve: { generator: 'npm-and-modules', paths: ['src', 'lib'], - extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + extensions: ['', '.js', '.jsx', '.es6.js', '.json'], }, loaders: [ 'esnextreact', diff --git a/lib/configs/DefaultProductionServerConfig.js b/lib/configs/ProductionServer.js similarity index 89% rename from lib/configs/DefaultProductionServerConfig.js rename to lib/configs/ProductionServer.js index 84664be..2ec7d05 100644 --- a/lib/configs/DefaultProductionServerConfig.js +++ b/lib/configs/ProductionServer.js @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'ProductionServer', webpack: { devtool: 'source-map', @@ -14,7 +14,7 @@ module.exports = { resolve: { generator: 'npm-and-modules', paths: ['src', 'lib'], - extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + extensions: ['', '.js', '.jsx', '.es6.js', '.json'], }, loaders: [ 'esnextreact', diff --git a/lib/configs/DefaultServerConfig.js b/lib/configs/Server.js similarity index 89% rename from lib/configs/DefaultServerConfig.js rename to lib/configs/Server.js index 23af7b6..91cc451 100644 --- a/lib/configs/DefaultServerConfig.js +++ b/lib/configs/Server.js @@ -1,4 +1,4 @@ -module.exports = { +export default { name: 'Server', webpack: { devtool: 'source-map', @@ -14,7 +14,7 @@ module.exports = { resolve: { generator: 'npm-and-modules', paths: ['src', 'lib'], - extensions: ['', '.js', '.jsx', '.es6.js', '.json'] + extensions: ['', '.js', '.jsx', '.es6.js', '.json'], }, loaders: [ 'esnextreact', diff --git a/lib/configs/DefaultTestingConfig.js b/lib/configs/Testing.js similarity index 90% rename from lib/configs/DefaultTestingConfig.js rename to lib/configs/Testing.js index 2d1f9cd..9728385 100644 --- a/lib/configs/DefaultTestingConfig.js +++ b/lib/configs/Testing.js @@ -1,6 +1,4 @@ -var _ = require('lodash'); - -module.exports = { +export default { name: 'Test', webpack: { devtool: 'source-map', @@ -26,5 +24,5 @@ module.exports = { generator: 'node-modules', additional: ['@r/platform/createTest'], }, - } -} + }, +}; diff --git a/lib/configs/index.js b/lib/configs/index.js index a01351b..1b34ce1 100644 --- a/lib/configs/index.js +++ b/lib/configs/index.js @@ -1,27 +1,14 @@ -var DefaultClientConfig = require('./DefaultClientConfig'); -var DefaultProductionClientConfig = require('./DefaultProductionClientConfig'); -var DefaultServerConfig = require('./DefaultServerConfig'); -var DefaultProductionServerConfig = require('./DefaultProductionServerConfig'); -var DefaultTestingConfig = require('./DefaultTestingConfig'); +import ClientConfig from './Client'; +import ProudctionClientConfig from './ProductionClient'; +import ServerConfig from './Server'; +import ProductionServerConfig from './ProductionServer'; -function getBuild(production, debugConfig, productionConfig) { +const getBuild = (production, debugConfig, productionConfig) => { return production ? productionConfig : debugConfig; -} - -function getClientConfig(production) { - return getBuild(production, DefaultClientConfig, DefaultProductionClientConfig); -} +}; -function getServerConfig(production) { - return getBuild(production, DefaultServerConfig, DefaultProductionServerConfig); -} +export const getClientConfig = production => ( + getBuild(production, ClientConfig, ProudctionClientConfig)); -module.exports = { - DefaultClientConfig, - DefaultProductionClientConfig, - DefaultServerConfig, - DefaultProductionServerConfig, - DefaultTestingConfig, - getClientConfig, - getServerConfig, -}; +export const getServerConfig = production => ( + getBuild(production, ServerConfig, ProductionServerConfig)); diff --git a/lib/generators/entry/index.js b/lib/generators/entry/index.js index 1ab76df..3c997e7 100644 --- a/lib/generators/entry/index.js +++ b/lib/generators/entry/index.js @@ -1,11 +1,6 @@ -var path = require('path'); -var _ = require('lodash'); -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; +import path from 'path'; -var entryGenerators = { -}; - -function getEntry(pathOrObject, buildName) { +export const getEntry = (pathOrObject, buildName) => { // for now takes the path to the file, and the build name and makes // the entry point object. in the future we can do things like auto traverers // the module paths you're resolving and generate tree-shaking-less umd ready builds @@ -15,12 +10,7 @@ function getEntry(pathOrObject, buildName) { return pathOrObject; } - var entryConfig = {}; + const entryConfig = {}; entryConfig[buildName] = path.resolve(pathOrObject); return entryConfig; }; - -module.exports = { - getEntry, - entryGenerators, -}; diff --git a/lib/generators/externals/index.js b/lib/generators/externals/index.js index 4b81ea5..504d6c7 100644 --- a/lib/generators/externals/index.js +++ b/lib/generators/externals/index.js @@ -1,14 +1,14 @@ -var loadNodeModules = require('./loadNodeModules'); +import { loadNodeModules } from './loadNodeModules'; -var loaderName = 'node-modules'; +const loaderName = 'node-modules'; -function getExternals(externals) { +export const getExternals = externals => { if (typeof externals === 'string') { if (externals === loaderName) { return loadNodeModules(); - } else { - throw new Error('invalid externals loader name, did you mean: ' + loaderName + '?'); } + + throw new Error(`Invalid externals loader name, did you mean: ${loaderName} ?`); } if (typeof externals === 'object') { @@ -18,8 +18,4 @@ function getExternals(externals) { return externals; } -} - -module.exports = { - getExternals, }; diff --git a/lib/generators/externals/loadNodeModules.js b/lib/generators/externals/loadNodeModules.js index 0a4a35c..4495863 100644 --- a/lib/generators/externals/loadNodeModules.js +++ b/lib/generators/externals/loadNodeModules.js @@ -1,17 +1,17 @@ -var fs = require('fs'); +import fs from 'fs'; -function prependCommonjs (modules, name) { - modules[name] = 'commonjs ' + name; +const prependCommonjs = (modules, name) => { + modules[name] = `commonjs ${name}`; return modules; -} +}; -var lodashSubmodules = [ +const lodashSubmodules = [ 'array', 'collection', 'date', 'function', 'lang', 'math', - 'number', 'object', 'seq', 'string', 'util', 'properties', 'methods' -].map(function(name) { return 'lodash/' + name }); + 'number', 'object', 'seq', 'string', 'util', 'properties', 'methods', +].map(name => `lodash/${name}`); -module.exports = function(additional) { - var nodeModules = {}; +export const loadNodeModules = additional => { + const nodeModules = {}; fs.readdirSync('node_modules') .filter(function(x) { return ['.bin'].indexOf(x) === -1; }) diff --git a/lib/generators/index.js b/lib/generators/index.js index f9bdb70..436155a 100644 --- a/lib/generators/index.js +++ b/lib/generators/index.js @@ -1,17 +1,55 @@ -var getLoader = require('./loaders').getLoader; -var getPlugin = require('./plugins').getPlugin; -var getOutput = require('./output').getOutput; -var getResolver = require('./resolver').getResolver; -var getEntry = require('./entry').getEntry; -var getExternals = require('./externals').getExternals; -var getPostCSS = require('./postcss').getPostCSS; - -module.exports = { - getLoader, - getPlugin, - getOutput, - getResolver, - getEntry, - getExternals, - getPostCSS, +export const Generator = (nameOrNames, objectOrFunction) => { + let names = nameOrNames; + if (!Array.isArray(names)) { + names = [ names ]; + } + + return { + names, + objectOrFunction, + }; +}; + +const applyGenerators = (loaders, generator) => { + generator.names.forEach(name => { + loaders[name] = generator.objectOrFunction; + }); + + return loaders; +}; + +export const generatorLoader = (thingKind, generators) => { + const loaders = generators.reduce((prev, generator) => applyGenerators({...prev}, generator), {}); + return (loaderName) => tryToLoadGenerator(loaderName, loaders, thingKind); +}; + +export const tryToLoadGenerator = (nameOrObject, lookupTable, thingKind) => { + const parsed = parseNameOrObject(nameOrObject); + if (!parsed) { + return nameOrObject; + } + + const thing = lookupTable[parsed.name]; + if (!thing) { + throw new Error(`Failed to resolve ${nameOrObject} - ${thingKind}`); + } + + if (typeof thing === 'function') { + return thing(parsed.options); + } + + return thing; +}; + +const parseNameOrObject = (nameOrObject) => { + if (typeof nameOrObject === 'string') { + return { name: nameOrObject, options: {} }; + } + + if (typeof nameOrObject === 'object') { + const name = nameOrObject.generator; + if (typeof name === 'string') { + return { name, options: nameOrObject }; + } + } }; diff --git a/lib/generators/loaders/CSS.js b/lib/generators/loaders/CSS.js new file mode 100644 index 0000000..28d8a3f --- /dev/null +++ b/lib/generators/loaders/CSS.js @@ -0,0 +1,8 @@ +import ExtractTextPlugin from 'extract-text-webpack-plugin'; + +import { Generator } from 'lib/generators'; + +export default Generator('css', { + test: /\.css$/, + loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'), +}); diff --git a/lib/generators/loaders/CSSLoader.js b/lib/generators/loaders/CSSLoader.js deleted file mode 100644 index 5918387..0000000 --- a/lib/generators/loaders/CSSLoader.js +++ /dev/null @@ -1,6 +0,0 @@ -var ExtractTextPlugin = require('extract-text-webpack-plugin'); - -module.exports = { - test: /\.css$/, - loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'), -}; diff --git a/lib/generators/loaders/ESNextReactLoader.js b/lib/generators/loaders/ESNextReact.js similarity index 76% rename from lib/generators/loaders/ESNextReactLoader.js rename to lib/generators/loaders/ESNextReact.js index 7d7ae8b..2b3afb4 100644 --- a/lib/generators/loaders/ESNextReactLoader.js +++ b/lib/generators/loaders/ESNextReact.js @@ -1,4 +1,6 @@ -module.exports = { +import { Generator } from 'lib/generators'; + +export default Generator(['esnextreact', 'ESNextReact'], { test: /\.es6\.js$|\.js$|\.jsx$/, exclude: /node_modules/, loader: 'babel', @@ -14,5 +16,5 @@ module.exports = { 'transform-react-inline-elements', 'lodash', // fixes the babel budnling issue ], - } -}; + }, +}); diff --git a/lib/generators/loaders/IgnoreStyles.js b/lib/generators/loaders/IgnoreStyles.js new file mode 100644 index 0000000..12616ad --- /dev/null +++ b/lib/generators/loaders/IgnoreStyles.js @@ -0,0 +1,6 @@ +import { Generator } from 'lib/generators'; + +export default Generator('ignore-styles', { + test: /\.css$|\.less$/, + loader: 'ignore-loader', +}); diff --git a/lib/generators/loaders/IgnoreStylesLoader.js b/lib/generators/loaders/IgnoreStylesLoader.js deleted file mode 100644 index 00bf5a2..0000000 --- a/lib/generators/loaders/IgnoreStylesLoader.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - test: /\.css$|\.less$/, - loader: 'ignore-loader', -}; diff --git a/lib/generators/loaders/JSON.js b/lib/generators/loaders/JSON.js new file mode 100644 index 0000000..245727e --- /dev/null +++ b/lib/generators/loaders/JSON.js @@ -0,0 +1,6 @@ +import { Generator } from 'lib/generators'; + +export default Generator('json', { + test: /\.json$/, + loader: 'json-loader', +}); diff --git a/lib/generators/loaders/JSONLoader.js b/lib/generators/loaders/JSONLoader.js deleted file mode 100644 index 19cc088..0000000 --- a/lib/generators/loaders/JSONLoader.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - test: /\.json$/, - loader: 'json-loader', -}; diff --git a/lib/generators/loaders/Less.js b/lib/generators/loaders/Less.js new file mode 100644 index 0000000..4f07140 --- /dev/null +++ b/lib/generators/loaders/Less.js @@ -0,0 +1,8 @@ +import ExtractTextPlugin from 'extract-text-webpack-plugin'; + +import { Generator } from 'lib/generators'; + +export default Generator('less', { + test: /\.less$/, + loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader'), +}); diff --git a/lib/generators/loaders/LessLoader.js b/lib/generators/loaders/LessLoader.js deleted file mode 100644 index 0e00f9a..0000000 --- a/lib/generators/loaders/LessLoader.js +++ /dev/null @@ -1,6 +0,0 @@ -var ExtractTextPlugin = require('extract-text-webpack-plugin'); - -module.exports = { - test: /\.less$/, - loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader'), -}; diff --git a/lib/generators/loaders/index.js b/lib/generators/loaders/index.js index 59618c3..394630c 100644 --- a/lib/generators/loaders/index.js +++ b/lib/generators/loaders/index.js @@ -1,25 +1,15 @@ -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; - -var ESNextReactLoader = require('./ESNextReactLoader'); -var JSONLoader = require('./JSONLoader'); -var CSSLoader = require('./CSSLoader'); -var LessLoader = require('./LessLoader'); -var IgnoreStylesLoader = require('./IgnoreStylesLoader'); - -var loaders = { - 'esnextreact': ESNextReactLoader, - 'ESNextReact': ESNextReactLoader, - 'json': JSONLoader, - 'css': CSSLoader, - 'less': LessLoader, - 'ignore-styles': IgnoreStylesLoader, -} - -var getLoader = function(loaderName) { - return tryToLoadGenerator(loaderName, loaders, 'loader'); -} - -module.exports = { - loaders, - getLoader, -}; +import { generatorLoader } from 'lib/generators'; + +import CSSLoader from './CSS'; +import ESNextReactLoader from './ESNextReact'; +import IgnoreStylesLoader from './IgnoreStyles'; +import JSONLoader from './JSON'; +import LessLoader from './Less'; + +export const getLoader = generatorLoader('loader', [ + CSSLoader, + ESNextReactLoader, + IgnoreStylesLoader, + JSONLoader, + LessLoader, +]); diff --git a/lib/generators/output/Library.js b/lib/generators/output/Library.js new file mode 100644 index 0000000..533256a --- /dev/null +++ b/lib/generators/output/Library.js @@ -0,0 +1,10 @@ +import { Generator } from 'lib/generators'; +import SimpleOutput from './Simple'; +const simple = SimpleOutput.objectOrFunction; // is a function + +export default Generator(['this', 'commonjs', 'commonjs2', 'amd', 'umd'], options => ({ + ...simple(options), + library: options.libraryName || '[name].js', + // use options.generator to know the name we've been passed, which will be one of the above ^ + libraryTarget: options.target || options.generator || 'var', +})); diff --git a/lib/generators/output/LibraryOutput.js b/lib/generators/output/LibraryOutput.js deleted file mode 100644 index 99ec556..0000000 --- a/lib/generators/output/LibraryOutput.js +++ /dev/null @@ -1,9 +0,0 @@ -var _ = require('lodash'); -var SimpleOutput = require('./SimpleOutput'); - -module.exports = function(options) { - return _.extend(SimpleOutput(options), { - library: options.libraryName || '[name].js', - libraryTarget: options.target || 'var', - }); -}; diff --git a/lib/generators/output/Simple.js b/lib/generators/output/Simple.js new file mode 100644 index 0000000..f6fa8b8 --- /dev/null +++ b/lib/generators/output/Simple.js @@ -0,0 +1,8 @@ +import path from 'path'; + +import { Generator } from 'lib/generators'; + +export default Generator('simple', options => ({ + path: path.resolve(options.dest), + filename: options.name || '[name].js', +})); diff --git a/lib/generators/output/SimpleOutput.js b/lib/generators/output/SimpleOutput.js deleted file mode 100644 index b891f0f..0000000 --- a/lib/generators/output/SimpleOutput.js +++ /dev/null @@ -1,8 +0,0 @@ -var path = require('path'); - -module.exports = function(options){ - return { - path: path.resolve(options.dest), - filename: options.name || '[name].js', - }; -}; diff --git a/lib/generators/output/index.js b/lib/generators/output/index.js index a8ba28c..1be9b9e 100644 --- a/lib/generators/output/index.js +++ b/lib/generators/output/index.js @@ -1,32 +1,9 @@ -var _ = require('lodash'); -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; +import { generatorLoader } from 'lib/generators'; -var SimpleOutput = require('./SimpleOutput'); -var LibraryOutput = require('./LibraryOutput'); +import LibraryOutput from './Library'; +import SimpleOutput from './Simple'; -function libraryOfTarget(target) { - return function(options) { - return LibraryOutput(_.extend(options, { - target: target, - })); - } -} - -var outputs = { - simple: SimpleOutput, - library: LibraryOutput, - this: libraryOfTarget('this'), - commonjs: libraryOfTarget('commonjs'), - commonjs2: libraryOfTarget('commonjs2'), - amd: libraryOfTarget('amd'), - umd: libraryOfTarget('umd'), -}; - -var getOutput = function(outputName) { - return tryToLoadGenerator(outputName, outputs, 'output'); -} - -module.exports = { - outputs, - getOutput, -} +export const getOutput = generatorLoader('output', [ + LibraryOutput, + SimpleOutput, +]); diff --git a/lib/generators/plugins/AbortIfErrors.js b/lib/generators/plugins/AbortIfErrors.js new file mode 100644 index 0000000..76dc717 --- /dev/null +++ b/lib/generators/plugins/AbortIfErrors.js @@ -0,0 +1,4 @@ +import { NoErrorsPlugin } from 'webpack'; +import { Generator } from 'lib/generators'; + +export default Generator('abort-if-errors', () => new NoErrorsPlugin()); diff --git a/lib/generators/plugins/AbortIfErrorsPlugin.js b/lib/generators/plugins/AbortIfErrorsPlugin.js deleted file mode 100644 index 4901468..0000000 --- a/lib/generators/plugins/AbortIfErrorsPlugin.js +++ /dev/null @@ -1,3 +0,0 @@ -var webpack = require('webpack'); - -module.exports = new webpack.NoErrorsPlugin(); diff --git a/lib/generators/plugins/BundleCommonChunks.js b/lib/generators/plugins/BundleCommonChunks.js new file mode 100644 index 0000000..517625e --- /dev/null +++ b/lib/generators/plugins/BundleCommonChunks.js @@ -0,0 +1,9 @@ +import { optimize } from 'webpack'; +const { CommonsChunkPlugin } = optimize; +import { Generator } from 'lib/generators'; + +export default Generator('bundle-common', () => (new CommonsChunkPlugin({ + name: 'vendor', + minChunks: Infinity, + filename: 'vendor.bundle.js', +}))); diff --git a/lib/generators/plugins/BundleCommonChunksPlugin.js b/lib/generators/plugins/BundleCommonChunksPlugin.js deleted file mode 100644 index f01c656..0000000 --- a/lib/generators/plugins/BundleCommonChunksPlugin.js +++ /dev/null @@ -1,7 +0,0 @@ -var webpack = require('webpack'); - -module.exports = new webpack.optimize.CommonsChunkPlugin({ - name: 'vendor', - minChunks: Infinity, - filename: 'vendor.bundle.js' - }); diff --git a/lib/generators/plugins/EnableProductionLoaders.js b/lib/generators/plugins/EnableProductionLoaders.js new file mode 100644 index 0000000..37a9d90 --- /dev/null +++ b/lib/generators/plugins/EnableProductionLoaders.js @@ -0,0 +1,7 @@ +import { LoaderOptionsPlugin } from 'webpack'; +import { Generator } from 'lib/generators'; + +export default Generator('production-loaders', () => (new LoaderOptionsPlugin({ + minimize: true, + debug: false, +}))); diff --git a/lib/generators/plugins/EnableProductionLoadersPlugin.js b/lib/generators/plugins/EnableProductionLoadersPlugin.js deleted file mode 100644 index 88519e5..0000000 --- a/lib/generators/plugins/EnableProductionLoadersPlugin.js +++ /dev/null @@ -1,6 +0,0 @@ -var webpack = require('webpack'); - -module.exports = new webpack.LoaderOptionsPlugin({ - minimize: true, - debug: false -}); diff --git a/lib/generators/plugins/ExtractCSS.js b/lib/generators/plugins/ExtractCSS.js new file mode 100644 index 0000000..84c3775 --- /dev/null +++ b/lib/generators/plugins/ExtractCSS.js @@ -0,0 +1,4 @@ +import ExtractTextPlugin from 'extract-text-webpack-plugin'; +import { Generator } from 'lib/generators'; + +export default Generator('extract-css', () => (new ExtractTextPlugin('[name].css'))); diff --git a/lib/generators/plugins/ExtractCSSPlugin.js b/lib/generators/plugins/ExtractCSSPlugin.js deleted file mode 100644 index 6cd0087..0000000 --- a/lib/generators/plugins/ExtractCSSPlugin.js +++ /dev/null @@ -1,3 +0,0 @@ -var ExtractTextPlugin = require('extract-text-webpack-plugin'); - -module.exports = new ExtractTextPlugin('[name].css'); diff --git a/lib/generators/plugins/MinifyAndTreeShake.js b/lib/generators/plugins/MinifyAndTreeShake.js new file mode 100644 index 0000000..d77449c --- /dev/null +++ b/lib/generators/plugins/MinifyAndTreeShake.js @@ -0,0 +1,9 @@ +import { optimize } from 'webpack'; +const { UglifyJsPlugin } = optimize; +import { Generator } from 'lib/generators'; + +export default Generator('minify-and-treeshake', () => (new UglifyJsPlugin({ + compress: { warnings: false }, + output: { comments: false }, + sourceMap: true, +}))); diff --git a/lib/generators/plugins/MinifyAndTreeShakePlugin.js b/lib/generators/plugins/MinifyAndTreeShakePlugin.js deleted file mode 100644 index 19467b9..0000000 --- a/lib/generators/plugins/MinifyAndTreeShakePlugin.js +++ /dev/null @@ -1,11 +0,0 @@ -var webpack = require('webpack'); - -module.exports = new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false - }, - output: { - comments: false - }, - sourceMap: true, -}); diff --git a/lib/generators/plugins/NodeExecutable.js b/lib/generators/plugins/NodeExecutable.js new file mode 100644 index 0000000..5d4982a --- /dev/null +++ b/lib/generators/plugins/NodeExecutable.js @@ -0,0 +1,8 @@ +import { BannerPlugin } from 'webpack'; +import { Generator } from 'lib/generators'; + +export default Generator('node-executable', () => (new BannerPlugin({ + banner: '#!/usr/bin/env node', + raw: true, + entryOnly: true, +}))); diff --git a/lib/generators/plugins/NodeLoadSourceMaps.js b/lib/generators/plugins/NodeLoadSourceMaps.js new file mode 100644 index 0000000..e406b4a --- /dev/null +++ b/lib/generators/plugins/NodeLoadSourceMaps.js @@ -0,0 +1,8 @@ +import { BannerPlugin } from 'webpack'; +import { Generator } from 'lib/generators'; + +export default Generator('node-load-sourcemaps', () => (new BannerPlugin({ + banner: 'require("source-map-support").install();', + raw: true, + entryOnly: false, +}))); diff --git a/lib/generators/plugins/NodeLoadSourceMapsPlugin.js b/lib/generators/plugins/NodeLoadSourceMapsPlugin.js deleted file mode 100644 index 9563328..0000000 --- a/lib/generators/plugins/NodeLoadSourceMapsPlugin.js +++ /dev/null @@ -1,7 +0,0 @@ -var webpack = require('webpack'); - -module.exports = new webpack.BannerPlugin({ - banner: 'require("source-map-support").install();', - raw: true, - entryOnly: false, -}); diff --git a/lib/generators/plugins/SetNodeEnvironment.js b/lib/generators/plugins/SetNodeEnvironment.js new file mode 100644 index 0000000..2710d29 --- /dev/null +++ b/lib/generators/plugins/SetNodeEnvironment.js @@ -0,0 +1,14 @@ +import { DefinePlugin } from 'webpack'; +import { Generator } from 'lib/generators'; + +export default Generator('set-node-env', options => { + const nodeEnv = process.env.NODE_ENV || 'production'; + const env = process.env.ENV || 'server'; + + return new DefinePlugin({ + 'process.env': { + NODE_ENV: JSON.stringify(options.nodeEnv || nodeEnv), + ENV: JSON.stringify(options.env || env), + }, + }); +}); diff --git a/lib/generators/plugins/SetNodeEnvironmentPlugin.js b/lib/generators/plugins/SetNodeEnvironmentPlugin.js deleted file mode 100644 index 1814e1f..0000000 --- a/lib/generators/plugins/SetNodeEnvironmentPlugin.js +++ /dev/null @@ -1,13 +0,0 @@ -var webpack = require('webpack'); - -var nodeEnv = process.env.NODE_ENV || 'production'; -var env = process.env.ENV || 'server'; - -module.exports = function(options) { - return new webpack.DefinePlugin({ - 'process.env': { - NODE_ENV: JSON.stringify(options.nodeEnv || nodeEnv), - ENV: JSON.stringify(options.env || env), - }, - }); -}; diff --git a/lib/generators/plugins/index.js b/lib/generators/plugins/index.js index e6dcf67..6c92a37 100644 --- a/lib/generators/plugins/index.js +++ b/lib/generators/plugins/index.js @@ -1,27 +1,21 @@ -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; -var AbortIfErrorsPlugin = require('./AbortIfErrorsPlugin'); -var BundleCommonChunksPlugin = require('./BundleCommonChunksPlugin'); -var EnableProductionLoadersPlugin = require('./EnableProductionLoadersPlugin'); -var ExtractCSSPlugin = require('./ExtractCSSPlugin'); -var MinifyAndTreeShakePlugin = require('./MinifyAndTreeShakePlugin'); -var NodeLoadSourceMapsPlugin = require('./NodeLoadSourceMapsPlugin'); -var SetNodeEnvironmentPlugin = require('./SetNodeEnvironmentPlugin'); +import { generatorLoader } from 'lib/generators'; -var plugins = { - 'abort-if-errors': AbortIfErrorsPlugin, - 'bundle-common': BundleCommonChunksPlugin, - 'extract-css': ExtractCSSPlugin, - 'production-loaders': EnableProductionLoadersPlugin, - 'minify-and-treeshake': MinifyAndTreeShakePlugin, - 'node-load-sourcemaps': NodeLoadSourceMapsPlugin, - 'set-node-env': SetNodeEnvironmentPlugin, -}; +import AbortIfErrorsPlugin from './AbortIfErrors'; +import BundleCommonChunksPlugin from './BundleCommonChunks'; +import EnableProductionLoadersPlugin from './EnableProductionLoaders'; +import ExtractCSSPlugin from './ExtractCSS'; +import MinifyAndTreeShakePlugin from './MinifyAndTreeShake'; +import NodeExecutablePlugin from './NodeExecutable'; +import NodeLoadSourceMapsPlugin from './NodeLoadSourceMaps'; +import SetNodeEnvironmentPlugin from './SetNodeEnvironment'; -function getPlugin(pluginName) { - return tryToLoadGenerator(pluginName, plugins, 'plugin'); -} - -module.exports = { - plugins, - getPlugin, -}; +export const getPlugin = generatorLoader('plugin', [ + AbortIfErrorsPlugin, + BundleCommonChunksPlugin, + EnableProductionLoadersPlugin, + ExtractCSSPlugin, + MinifyAndTreeShakePlugin, + NodeExecutablePlugin, + NodeLoadSourceMapsPlugin, + SetNodeEnvironmentPlugin, +]); diff --git a/lib/generators/postcss/Autoprefixer.js b/lib/generators/postcss/Autoprefixer.js new file mode 100644 index 0000000..ae11012 --- /dev/null +++ b/lib/generators/postcss/Autoprefixer.js @@ -0,0 +1,6 @@ +import { Generator } from 'lib/generators'; +import autoprefixer from 'autoprefixer'; + +export default Generator('autoprefixer', options => (autoprefixer({ + browsers: [`last ${options.numVersions || 2} versions` ], +}))); diff --git a/lib/generators/postcss/AutoprexiferPostCSS.js b/lib/generators/postcss/AutoprexiferPostCSS.js deleted file mode 100644 index a2ea3c1..0000000 --- a/lib/generators/postcss/AutoprexiferPostCSS.js +++ /dev/null @@ -1,5 +0,0 @@ -var autoprefixer = require('autoprefixer'); - -module.exports = function(options) { - return autoprefixer({ browsers: ['last ' + options.numVersions + ' versions']}); -}; diff --git a/lib/generators/postcss/index.js b/lib/generators/postcss/index.js index 4094335..f7f85b6 100644 --- a/lib/generators/postcss/index.js +++ b/lib/generators/postcss/index.js @@ -1,16 +1,6 @@ -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; -var AutoprefixerPostCSS = require('./AutoprexiferPostCSS'); +import { generatorLoader } from 'lib/generators'; +import Autoprefixer from './Autoprefixer'; -var postCSSHooks = { - 'autoprefixer-custom': AutoprefixerPostCSS, - 'autoprefixer': AutoprefixerPostCSS({ numVersions: 2 }), -}; - -var getPostCSS = function(postCSSHookName) { - return tryToLoadGenerator(postCSSHookName, postCSSHooks, 'postcsshooks'); -} - -module.exports = { - postCSSHooks, - getPostCSS, -}; +export const getPostCSS = generatorLoader('postcsshooks', [ + Autoprefixer, +]); diff --git a/lib/generators/resolver/Modules.js b/lib/generators/resolver/Modules.js new file mode 100644 index 0000000..1e82218 --- /dev/null +++ b/lib/generators/resolver/Modules.js @@ -0,0 +1,11 @@ +import path from 'path'; +import { Generator } from 'lib/generators'; +import SimpleResolver from './Simple'; +const simple = SimpleResolver.objectOrFunction; // its a function; + +const resolvePath = strPath => path.resolve(strPath); + +export default Generator('modules', options => ({ + ...simple(options), + modules: (options.paths || []).map(resolvePath), +})); diff --git a/lib/generators/resolver/ModulesResolver.js b/lib/generators/resolver/ModulesResolver.js deleted file mode 100644 index 1e10ee7..0000000 --- a/lib/generators/resolver/ModulesResolver.js +++ /dev/null @@ -1,13 +0,0 @@ -var _ = require('lodash'); -var path = require('path'); -var SimpleResolver = require('./SimpleResolver'); - -function resolvePath(strPath) { - return path.resolve(strPath); // path.resolve seems to have a binding issue; -} - -module.exports = function(options){ - return _.extend(SimpleResolver(options), { - modules: (options.paths || []).map(resolvePath), - }); -} diff --git a/lib/generators/resolver/NPMAndModules.js b/lib/generators/resolver/NPMAndModules.js new file mode 100644 index 0000000..f22acc1 --- /dev/null +++ b/lib/generators/resolver/NPMAndModules.js @@ -0,0 +1,11 @@ +import { Generator } from 'lib/generators'; +import ModulesResolver from './Modules'; +const modules = ModulesResolver.objectOrFunction; // its a function; + +export default Generator('npm-and-modules', options => { + const result = modules(options); + return { + ...result, + modules: result.modules.concat('node_modules'), + }; +}); diff --git a/lib/generators/resolver/NPMAndModulesResolver.js b/lib/generators/resolver/NPMAndModulesResolver.js deleted file mode 100644 index 4cb40ea..0000000 --- a/lib/generators/resolver/NPMAndModulesResolver.js +++ /dev/null @@ -1,8 +0,0 @@ -var _ = require('lodash'); -var ModulesResolver = require('./ModulesResolver'); - -module.exports = function(options){ - var result = ModulesResolver(options); - result.modules = result.modules.concat('node_modules'); - return result; -} diff --git a/lib/generators/resolver/Simple.js b/lib/generators/resolver/Simple.js new file mode 100644 index 0000000..aa1e105 --- /dev/null +++ b/lib/generators/resolver/Simple.js @@ -0,0 +1,5 @@ +import { Generator } from 'lib/generators'; + +export default Generator('simple', options => ({ + extensions: options.extensions, +})); diff --git a/lib/generators/resolver/SimpleResolver.js b/lib/generators/resolver/SimpleResolver.js deleted file mode 100644 index fe209c5..0000000 --- a/lib/generators/resolver/SimpleResolver.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = function(options) { - return { - extensions: options.extensions, - }; -} diff --git a/lib/generators/resolver/index.js b/lib/generators/resolver/index.js index ef3c4fc..637aada 100644 --- a/lib/generators/resolver/index.js +++ b/lib/generators/resolver/index.js @@ -1,20 +1,11 @@ -var tryToLoadGenerator = require('../tryToLoadGenerator').tryToLoadGenerator; +import { generatorLoader } from 'lib/generators'; -var SimpleResolver = require('./SimpleResolver'); -var ModulesResolver = require('./ModulesResolver'); -var NPMAndModulesResolver = require('./NPMAndModulesResolver'); +import ModulesResolver from './Modules'; +import NPMAndModulesResolver from './NPMAndModules'; +import Simple from './Simple'; -var resolvers = { - 'simple': SimpleResolver, - 'modules': ModulesResolver, - 'npm-and-modules': NPMAndModulesResolver, -}; - -function getResolver(resolverName) { - return tryToLoadGenerator(resolverName, resolvers, 'resolver'); -} - -module.exports = { - resolvers, - getResolver, -} +export const getResolver = generatorLoader('resolver', [ + ModulesResolver, + NPMAndModulesResolver, + Simple, +]); diff --git a/lib/generators/tryToLoadGenerator.js b/lib/generators/tryToLoadGenerator.js deleted file mode 100644 index 3344b07..0000000 --- a/lib/generators/tryToLoadGenerator.js +++ /dev/null @@ -1,36 +0,0 @@ -var _ = require('lodash'); - -function tryToLoadGenerator(nameOrObject, lookupTable, thingKind) { - var parsed = parseNameOrObject(nameOrObject); - if (!parsed) { - return nameOrObject; - } - - var thing = lookupTable[parsed.name]; - if (!thing){ - throw new Error('Failed to resolve ' + nameOrObject + ' ' + thingKind); - return; - } - if (typeof thing === 'function') { - return thing(parsed.options); - } - - return thing; -} - -function parseNameOrObject(nameOrObject) { - if (typeof nameOrObject === 'string') { - return { name: nameOrObject, options: {} }; - } - - if (typeof nameOrObject === 'object') { - var name = nameOrObject.generator; - if (typeof name === 'string') { - return { name, options: _.omit(nameOrObject, 'name') }; - } - } -} - -module.exports = { - tryToLoadGenerator -}; diff --git a/lib/getTestFiles.js b/lib/getTestFiles.js index 24193dc..45a6fa9 100644 --- a/lib/getTestFiles.js +++ b/lib/getTestFiles.js @@ -1,11 +1,10 @@ -var _ = require('lodash'); -var fs = require('fs'); +import fs from 'fs'; -module.exports = function getTestFiles(dir, ext) { +export const getTestFiles = (dir, ext) => { if (dir.indexOf('node_modules') > -1) { return; } if (dir.indexOf('.git') > -1) { return; } - var files = []; + let files = []; try { files = fs.readdirSync(dir); } catch (e) { @@ -13,25 +12,24 @@ module.exports = function getTestFiles(dir, ext) { } return files - .map(function(file) { - var path = dir + file; + .map(file => { + const path = `${dir}${file}`; try { - var stats = fs.statSync(path); - if (stats.isDirectory()) { return getTestFiles(path + '/', ext); } + const stats = fs.statSync(path); + if (stats.isDirectory()) { return getTestFiles(`${path}/${ext}`); } if (file.indexOf(ext) > -1) { return { file, path }; } return null; - } - catch (e) { + } catch (e) { return null; } }) - .filter(function(x) { return x; }) - .reduce(function(prev, cur) { - if (_.isArray(cur)) { + .filter(x => x) + .reduce((prev, cur) => { + if (Array.isArray(cur)) { return prev.concat(cur); - } else { - return prev.concat([cur]); } + + return prev.concat([cur]); }, []); }; diff --git a/lib/getWebpackEntryForTest.js b/lib/getWebpackEntryForTest.js index db5c92a..7da1033 100644 --- a/lib/getWebpackEntryForTest.js +++ b/lib/getWebpackEntryForTest.js @@ -1,12 +1,16 @@ -var getTestFiles = require('./getTestFiles'); +import colors from 'colors'; +import { getTestFiles } from './getTestFiles'; -module.exports = function getWebpackEntryForTest(dir) { - console.log(' Searching for tests in', process.cwd()); - var files = getTestFiles(dir, '.test.'); - console.log(' Found ' + files.length + ' test' + (files.length > 1 ? 's' : '')); +const { magenta } = colors; - return files.reduce(function(prev, cur) { - var moduleName = cur.path.split('.test')[0].split('./')[1] + '.compiledtest'; +export const getWebpackEntryForTest = dir => { + console.log(magenta(`Searching for tests in ${process.cwd()}`)); + + const files = getTestFiles(dir, '.test.'); + console.log(magenta(`Found ${files.length} test${files.length ? 's' : ''}`)); + + return files.reduce((prev, cur) => { + const moduleName = `${cur.path.split('.test')[0].split('./')[1]}.compiledtest`; prev[moduleName] = cur.path; return prev; }, {}); diff --git a/lib/makeBuild.js b/lib/makeBuild.js index 21cda0a..9b6115c 100644 --- a/lib/makeBuild.js +++ b/lib/makeBuild.js @@ -1,90 +1,41 @@ -var _ = require('lodash'); -var generators = require('./generators'); -var getLoader = generators.getLoader; -var getPlugin = generators.getPlugin; -var getOutput = generators.getOutput; -var getResolver = generators.getResolver; -var getEntry = generators.getEntry; -var getPostCSS = generators.getPostCSS; -var getExternals = generators.getExternals; - - -function makeBuild(shortBuild) { - return buildObject(shortBuild.name, - shortBuild.watch, - parseWebpackConfig(shortBuild.webpack, shortBuild.name)) -} +import { omit } from 'lodash/object'; + +import { getLoader } from 'lib/generators/loaders'; +import { getPlugin } from 'lib/generators/plugins'; +import { getOutput } from 'lib/generators/output'; +import { getResolver } from 'lib/generators/resolver'; +import { getEntry } from 'lib/generators/entry'; +import { getPostCSS } from 'lib/generators/postcss'; +import { getExternals } from 'lib/generators/externals'; + +// ShortBuild is an object that looks like { +// name: String, +// watch: Bool, +// webpack: Object, shorthand webpack config +//} + +export const makeBuild = shortBuild => ({ + ...shortBuild, + wepback: parseWebpackConfig(shortBuild.webpack, shortBuild.name), +}); + +const mapNullable = (arrayOrNull, fn) => (arrayOrNull || []).map(fn); + +const parseWebpackConfig = (shortHandConfig, buildName) => { + const webpackConfig = { + entry: getEntry(shortHandConfig.entry, buildName), + output: getOutput(shortHandConfig.output), + module: { + loaders: mapNullable(shortHandConfig.loaders, getLoader), + }, + plugins: mapNullable(shortHandConfig.plugins, getPlugin), + resolve: getResolver(shortHandConfig.resolve), + postcss: mapNullable(shortHandConfig.postcss, getPostCSS), + externals: getExternals(shortHandConfig.externals), + }; -function buildObject(buildName, watch, webpackConfig) { return { - watch, - buildName, - webpackConfig, + ...webpackConfig, + ...omit(shortHandConfig, Object.keys(webpackConfig).concat('loaders')), }; -} - -function parseWebpackConfig(shortHandConfig, buildName) { - var webpackConfig = {}; - - Object.keys(shortHandConfig).forEach(function(key) { - var obj = shortHandConfig[key]; - - if (key === 'loaders') { - _.defaults(webpackConfig, { module: { loaders: [] }}); - concatInPlace( - webpackConfig.module.loaders, - obj.map(getLoader) - ); - } - - if (key === 'plugins') { - webpackConfig.plugins = obj.map(getPlugin); - } - - if (key === 'output') { - webpackConfig.output = getOutput(obj); - } - - if (key === 'resolve') { - webpackConfig.resolve = getResolver(obj); - } - - if (key === 'entry') { - webpackConfig.entry = getEntry(obj, buildName); - } - - if (key === 'postcss') { - webpackConfig.postcss = obj.map(getPostCSS); - } - - if (key === 'externals') { - webpackConfig.externals = getExternals(obj); - } - }); - - return _.extend(webpackConfig, _.omit(shortHandConfig, - Object.keys(webpackConfig).concat('loaders'))); -} - -function concatInPlace(dest, source) { - source.forEach(function(thing) { dest.push(thing) }); -} - -function loadNameOrUseSource(thing, load) { - if (typeof thing === 'string') { - return load(thing); - } - - return thing; -} - -function mapLoadNameOrUseSource(array, loader) { - return array.map(loader); -} - -module.exports = { - makeBuild, - buildObject, - parseWebpackConfig, - loadNameOrUseSource, }; diff --git a/lib/output/SimpleOutput.js b/lib/output/SimpleOutput.js deleted file mode 100644 index 09bedee..0000000 --- a/lib/output/SimpleOutput.js +++ /dev/null @@ -1,9 +0,0 @@ -var path = require('path'); - -module.exports = function(options){ - return { - path: path.join(process.cwd(), options.dest), - filename: options.name || '[name].js', - sourceMapFilename: '[name].js.map', - }; -}; diff --git a/package.json b/package.json index 27dd2b0..6e5e29e 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,15 @@ { "name": "@r/build", - "version": "0.6.2", + "version": "0.7.0", "description": "A webpack based build system that can make UMD modules, (soon)peer-dependent library builds, server 'binarys', or full client ready scripts", "scripts": { - "lint": "eslint lib" + "lint": "eslint lib src", + "build": "blueprints", + "watch": "blueprints -w" }, "bin": { - "blueprints": "./bin/buildBlueprints.js", - "webfonts": "./bin/buildWebfonts.js" + "blueprints": "./bin/blueprints.js", + "webfonts": "./bin/webfonts.js" }, "repository": { "type": "git", @@ -43,16 +45,19 @@ "json-loader": "^0.5.4", "less": "^2.7.1", "less-loader": "^2.2.3", + "lodash": "4.x", + "mocha": "^2.4.5", "node-notifier": "^4.5.0", "postcss-loader": "^0.9.1", "rimraf": "^2.5.2", + "source-map-support": "^0.4.0", "style-loader": "^0.13.1", "webfonts-generator": "^0.3.5", "webpack": "^2.1.0-beta.7", - "yargs": "^4.6.0", - "mocha": "^2.4.5" + "yargs": "^4.6.0" }, "devDependencies": { + "@r/build": "git://github.com/schwers/node-build#2bef8806fea324147cfd38bdf12834bff201932a", "babel-cli": "^6.7.5", "babel-eslint": "^6.0.4", "eslint": "^2.8.0", diff --git a/src/blueprints.js b/src/blueprints.js new file mode 100755 index 0000000..aa82585 --- /dev/null +++ b/src/blueprints.js @@ -0,0 +1,167 @@ +import { omit } from 'lodash/object'; +import colors from 'colors'; +import debugModule from 'debug'; +import Mocha from 'mocha'; +import path from 'path'; +import rimraf from 'rimraf'; +import yargs from 'yargs'; + +import { build } from 'lib/build'; +import { makeBuild } from 'lib/makeBuild'; +import { getClientConfig, getServerConfig } from 'lib/configs'; +import TestingConfig from 'lib/configs/Testing'; +import { getWebpackEntryForTest } from 'lib/getWebpackEntryForTest'; + +const debug = debugModule('blueprints'); + +const { blue, white, magenta, red } = colors; + +/* eslint-disable max-len */ +const argv = yargs + .alias('b', 'blueprintsPath') + .describe('b', 'path to a raw-config via a node file with moduel.exports = config') + .default('b', './blueprints.config.js') + .alias('p', 'production') + .describe('p', 'enable production settings for the default build cofings') + .default('p', false) + .alias('c', 'client') + .describe('c', 'use the default client build, assumes you have an entry point to a client at ~/lib/client.[some es6.js or .js or .jsx]') + .default('c', false) + .alias('s', 'server') + .describe('s', 'use the default server build, assumes you have an entry point to a server at ~/lib/server[some es6.js or .js or .jsx]') + .default('s', false) + .alias('a', 'clientAndServer') + .describe('a', '[DEFAULT=true] use both a client and a server build. checks if you have an extend build and applies it.') + .default('a', true) + .alias('w', 'watch') + .describe('w', '[DEFAULT=false] force watching of all builds') + .default('w', false) + .alias('i', 'ignoreBlueprints') + .describe('ignore the blueprints.config.js file in the current directory and use defaults') + .default('i', false) + .alias('t', 'runTest') + .describe('search for test files and run them') + .default('t', false) + .argv; +/* eslint-enable */ + +const loadBuildsFromPath = filePath => { + try { + console.log(blue(`..loading config ${filePath}`)); + /* eslint-disable no-undef */ + // SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE is our hook outside of + // webpack's normal requires -- webpack normally resolves requires at compile time + // and turns require statments that are dynamic, or that it can't resolve, into error throwing + // thunks. I tried doing this with require.ensure, and webpack turned that into + // error throwing thunks as well, so this seems like the 'cleanest' solution. + let builds = SUPER_SECRET_REQUIRE_ONLY_CONFIG_LOADING_SHOULD_USE(path.resolve(filePath)); + /* eslint-enable */ + if (!Array.isArray(builds)) { + if (builds.extensions === true) { + return { extensions: omit(builds, 'extensions') }; + } + builds = [builds]; + } + + return { builds }; + } catch (e) { + debug(e); + return {}; + } +}; + +const loadDefaultConfigs = options => { + console.log(blue('..using default configs')); + if (options.runTest) { + console.log(magenta('..Setting up tests:')); + return [{ + ...TestingConfig, + ...{ + webpack: { + entry: getWebpackEntryForTest('./'), + }, + }, + }]; + } else if (options.client) { + console.log(blue('..client')); + return [ getClientConfig(options.production) ]; + } else if (options.server) { + console.log(blue('..server')); + return [ getServerConfig(options.production) ]; + } else if (options.clientAndServer) { + console.log(blue('..both')); + return [ + getClientConfig(options.production), + getServerConfig(options.production), + ]; + } + + return []; +}; + +const makeConfig = options => { + console.log(blue(`[Blueprints] reading from ${options.blueprintsPath}`)); + console.log(blue(`[cwd] ${process.cwd()}`)); + + let builds = []; + let extensions = {}; + + if (options.blueprintsPath && !options.ignoreBlueprints) { + const blueprints = loadBuildsFromPath(options.blueprintsPath); + if (blueprints.extensions) { + extensions = blueprints.extensions; + } else if (blueprints.builds && blueprints.builds.length) { + builds = blueprints.builds; + } + } + + if (!builds.length) { + loadDefaultConfigs(); + } + + if (options.watch) { + extensions.watch = true; + } + + return { + builds: applyExtensions(builds, extensions).map(makeBuild), + }; +}; + +const applyExtensions = (builds, extensions) => { + const ext = extensions || {}; + if (Object.keys(ext).length > 0) { + console.log(`${blue('[extensions]')}: ${white(JSON.stringify( + extensions, null, 2))}`); + } + + return builds.map(build => ({ ...build, ...ext })); +}; + +build(makeConfig(argv), stats => { + if (stats.errors && stats.errors.length > 0 && !argv.watch) { + console.log(red( + 'ERROR IN BUILD. Aborting.' + )); + + process.exit(1); + } + + if (argv.runTest) { + console.log(magenta( + '\n ******************************' + + '\n * RUNNING TESTS *' + + '\n ******************************' + )); + + const mochaInstance = new Mocha(); + stats.assets.forEach(asset => { + mochaInstance.addFile(`./.test/${asset.name}`); + }); + + mochaInstance.run() + .on('end', function() { + rimraf('./.test/', function() {}); + }); + } +}); diff --git a/src/webfonts.js b/src/webfonts.js new file mode 100755 index 0000000..e4efe48 --- /dev/null +++ b/src/webfonts.js @@ -0,0 +1,28 @@ +import colors from 'colors'; +import glob from 'glob'; +import path from 'path'; +import webfontsGenerator from 'webfonts-generator'; + +const SRC = path.resolve('./assets/svg/*.svg'); + +glob(SRC, (error, files) => { + /* eslint-disable max-len */ + console.log(`${colors.yellow('[Webfonts] generating from')} ${colors.white(JSON.stringify(files, null, 2))}`); + /* eslint-enable */ + + if (error) { + console.log(`${colors.red('[Error]')} ${colors.white(JSON.stringify(error, null, 2))}`); + } + + webfontsGenerator({ + files, + dest: path.resolve('./assets/fonts'), + fontName: 'rfont', + css: true, + cssDest: path.resolve('./assets/fonts/rfont.css'), + cssFontsUrl: '/fonts', + html: true, + types: ['svg', 'ttf', 'woff', 'eot'], + normalize: true, + }); +});