UNPKG

react-cosmos

Version:

CLI for running React Cosmos inside webpack-powered apps

36 lines (28 loc) 1.42 kB
"use strict"; var _detectCosmosConfig = require("../../../config/detectCosmosConfig"); var _generateUserDepsModule = require("../../../userDeps/generateUserDepsModule"); var _dom = require("../cosmosConfig/dom"); module.exports = function injectUserDeps() { var _this = this; var cosmosConfig = (0, _detectCosmosConfig.detectCosmosConfig)(); // This ensures this loader is invalidated whenever a new file is added to or // removed from user's project, which in turn triggers react-cosmos-voyager2 // to detect fixture files and finally update fixture list inside Playground. // Note that while this may not be very performant, it's not the equivalent // of require.context, which not only watches for file changes but also // automatically bundles new files that match the watcher's query. // https://github.com/webpack/webpack/issues/222#issuecomment-40691546 var watchDirs = cosmosConfig.watchDirs; watchDirs.forEach(function (watchDir) { return _this.addContextDependency(watchDir); }); var _createDomCosmosConfi = (0, _dom.createDomCosmosConfig)(cosmosConfig), containerQuerySelector = _createDomCosmosConfi.containerQuerySelector; var rendererConfig = { containerQuerySelector: containerQuerySelector }; return (0, _generateUserDepsModule.generateUserDepsModule)({ cosmosConfig: cosmosConfig, rendererConfig: rendererConfig, relativeToDir: null }); };