telefunc
Version:
Remote functions. Instead of API.
25 lines (24 loc) • 897 B
JavaScript
export { apply };
import { assert } from '../utils.js';
import { isViteCliCall } from './isViteCliCall.js';
function apply(when, { skipMiddlewareMode, onlyViteCli } = {}) {
return (config, { command, mode }) => {
var _a;
assert(command);
assert(mode);
if (onlyViteCli && !isViteCliCall({ command: when })) {
return false;
}
if (when === 'dev') {
if (skipMiddlewareMode === true && ((_a = config === null || config === void 0 ? void 0 : config.server) === null || _a === void 0 ? void 0 : _a.middlewareMode)) {
return false;
}
return command === 'serve' && mode === 'development';
}
assert(skipMiddlewareMode === undefined);
if (when === 'preview') {
return command === 'serve' && mode === 'production';
}
assert(false);
};
}