mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-02 12:07:02 +00:00
move mockserver to standalone section only
This commit is contained in:
@@ -6,9 +6,6 @@ import { Plugin, PluginOption, defineConfig } from 'vite';
|
|||||||
import viteImagemin from 'vite-plugin-imagemin';
|
import viteImagemin from 'vite-plugin-imagemin';
|
||||||
import zlib from 'zlib';
|
import zlib from 'zlib';
|
||||||
|
|
||||||
// @ts-expect-error - mock server doesn't have type declarations
|
|
||||||
import mockServer from '../mock-api/mockServer.js';
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
const KB_DIVISOR = 1024;
|
const KB_DIVISOR = 1024;
|
||||||
const REPEAT_CHAR = '=';
|
const REPEAT_CHAR = '=';
|
||||||
@@ -100,6 +97,10 @@ const createPreactPlugin = (devToolsEnabled: boolean) =>
|
|||||||
|
|
||||||
// Patch preact/compat to export stub React 19 APIs (use, useOptimistic) so that
|
// Patch preact/compat to export stub React 19 APIs (use, useOptimistic) so that
|
||||||
// react-router v7 doesn't trigger IMPORT_IS_UNDEFINED warnings from Rolldown.
|
// react-router v7 doesn't trigger IMPORT_IS_UNDEFINED warnings from Rolldown.
|
||||||
|
// Rolldown tracks the constant strings used in `React[REACT_USE]` /
|
||||||
|
// `React[USE_OPTIMISTIC]` lookups inside react-router and resolves them
|
||||||
|
// statically, so simply relying on a runtime guard is not enough — we need
|
||||||
|
// matching (stub) exports on the aliased preact/compat module.
|
||||||
const preactCompatPatchPlugin = (): Plugin => ({
|
const preactCompatPatchPlugin = (): Plugin => ({
|
||||||
name: 'preact-compat-react19-patch',
|
name: 'preact-compat-react19-patch',
|
||||||
transform(code, id) {
|
transform(code, id) {
|
||||||
@@ -210,9 +211,11 @@ const imageOptimizationPlugin = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default defineConfig(
|
export default defineConfig(
|
||||||
({ command, mode }: { command: string; mode: string }) => {
|
async ({ command, mode }: { command: string; mode: string }) => {
|
||||||
if (command === 'serve') {
|
if (command === 'serve') {
|
||||||
console.log(`Preparing for standalone build with server, mode=${mode}`);
|
console.log(`Preparing for standalone build with server, mode=${mode}`);
|
||||||
|
// @ts-expect-error - mock server doesn't have type declarations
|
||||||
|
const { default: mockServer } = await import('../mock-api/mockServer.js');
|
||||||
return {
|
return {
|
||||||
plugins: [...createBasePlugins(true, true), mockServer()],
|
plugins: [...createBasePlugins(true, true), mockServer()],
|
||||||
resolve: {
|
resolve: {
|
||||||
|
|||||||
Reference in New Issue
Block a user