UNPKG

react-cosmos

Version:

CLI for running React Cosmos inside webpack-powered apps

30 lines (22 loc) 937 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getStaticPath = getStaticPath; exports.serveStaticDir = serveStaticDir; var _express = _interopRequireDefault(require("express")); var _path = _interopRequireDefault(require("path")); var _utils = require("./utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function getStaticPath(relPath) { return _path.default.join(__dirname, 'static', relPath); } function serveStaticDir(app, staticPath, publicUrl) { var relStaticPath = _path.default.relative(process.cwd(), staticPath); console.log("[Cosmos] Serving static files from ".concat(relStaticPath)); app.use((0, _utils.removeLeadingDot)(publicUrl), _express.default.static(staticPath, { // Ensure loader index (generated by html-webpack-plugin) loads instead // of the index.html from staticPath index: false })); }