UNPKG

@viewdo/dxp-story-cli

Version:

DXP Story Management CLI

52 lines (42 loc) 1.34 kB
// @ts-nocheck const path = require("path"); const getConfig = require("./webpack.config"); const HtmlReplaceWebpackPlugin = require("html-replace-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const HtmlWebpackInjector = require("html-webpack-injector"); const { watchConfigs, load, setupMockXAPI, previewReplacements, } = require("@viewdo/dxp-story-cli/dist/tools"); module.exports = (env, meta) => { let { KEY: key = path.basename(path.resolve(process.cwd())), EPISODE: episode = "default", } = process.env; const config = getConfig(env, meta, "preview"); const basePath = path.resolve(__dirname); config.mode = "development"; const storyConfig = load(__dirname, "story-config"); if (storyConfig.host != "Hosted") throw new Error(`Using deprecated host type: ${storyConfig.host}`); config.devServer = { static: { directory: basePath, watch: true }, historyApiFallback: true, setupMiddlewares: (middlewares, devServer) => { if (!devServer) { throw new error('webpack-dev-server is not defined') } middlewares[setupMockXAPI(basePath, key, episode)(devServer)]; return middlewares; } }; config.plugins.push( new HtmlReplaceWebpackPlugin(previewReplacements(basePath)) ); return config; };