UNPKG

@lark-project/cli

Version:

飞书项目插件开发工具

69 lines (68 loc) 2.33 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDevServerConfig = void 0; const path_1 = __importDefault(require("path")); const paths_1 = __importDefault(require("./paths")); const pluginInfoMiddleware_1 = require("../middleware/pluginInfoMiddleware"); const env_1 = require("../../utils/env"); function ignoredFiles(pluginSrc) { return new RegExp(`^(?!${encodeURIComponent(path_1.default.normalize(pluginSrc + '/').replace(/[\\]+/g, '/'))}).+/node_modules/`, 'g'); } const getDevServerConfig = (proxy, serverOptions) => { return { allowedHosts: 'all', headers: { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': '*', 'Access-Control-Allow-Headers': '*', }, compress: true, liveReload: true, static: { directory: paths_1.default.pluginPublic, publicPath: [paths_1.default.publicUrlOrPath], watch: { ignored: ignoredFiles(paths_1.default.pluginSrc), }, }, client: { webSocketURL: { hostname: 'localhost', pathname: env_1.env.sockPath, port: env_1.env.sockPort, protocol: 'wss', }, overlay: { errors: true, runtimeErrors: false, warnings: false, }, progress: true, }, devMiddleware: { publicPath: paths_1.default.publicUrlOrPath, }, hot: true, server: { type: 'https', options: serverOptions, }, host: env_1.env.host, historyApiFallback: { disableDotRule: true, index: paths_1.default.publicUrlOrPath, }, proxy, setupMiddlewares(middlewares, devServer) { if (!devServer) { throw new Error('webpack-dev-server is not defined'); } (0, pluginInfoMiddleware_1.pluginInfoMiddleware)(devServer); return middlewares; }, }; }; exports.getDevServerConfig = getDevServerConfig;