diff --git a/core/docz-core/src/commands/build.ts b/core/docz-core/src/commands/build.ts index 308835fdc..3e471a16b 100644 --- a/core/docz-core/src/commands/build.ts +++ b/core/docz-core/src/commands/build.ts @@ -23,7 +23,7 @@ export const build = async (args: Arguments) => { dataServer.register([states.config(config), states.entries(entries, config)]) try { - await Entries.writeApp(config, true) + await Entries.writeApp(config, false) await Entries.writeImports(await entries.get()) await dataServer.start() await run('onPreBuild', config) diff --git a/core/docz-core/src/lib/Entries.ts b/core/docz-core/src/lib/Entries.ts index 0ef4d24dd..06378f60c 100644 --- a/core/docz-core/src/lib/Entries.ts +++ b/core/docz-core/src/lib/Entries.ts @@ -32,13 +32,14 @@ const writeAppFiles = async (config: Config, dev: boolean): Promise => { const onPreRenders = props('onPreRender') const onPostRenders = props('onPostRender') + const isProd = !dev const root = await compiled(fromTemplates('root.tpl.js'), { minimize: false }) const js = await compiled(fromTemplates('index.tpl.js'), { minimize: false }) const websocketUrl = `ws://${config.websocketHost}:${config.websocketPort}` const rawRootJs = root({ theme, - isProd: !dev, + isProd, wrapper: config.wrapper, websocketUrl, }) @@ -46,7 +47,7 @@ const writeAppFiles = async (config: Config, dev: boolean): Promise => { const rawIndexJs = js({ onPreRenders, onPostRenders, - isProd: !dev, + isProd, }) await fs.remove(paths.rootJs) @@ -58,9 +59,9 @@ const writeAppFiles = async (config: Config, dev: boolean): Promise => { export type EntryMap = Record export class Entries { - public static async writeApp(config: Config, dev?: boolean): Promise { + public static async writeApp(config: Config, dev: boolean): Promise { await fs.ensureDir(paths.app) - await writeAppFiles(config, Boolean(dev)) + await writeAppFiles(config, dev) } public static async writeImports(map: EntryMap): Promise { diff --git a/core/docz-core/templates/root.tpl.js b/core/docz-core/templates/root.tpl.js index 5f4e97db0..cef78928e 100644 --- a/core/docz-core/templates/root.tpl.js +++ b/core/docz-core/templates/root.tpl.js @@ -1,5 +1,5 @@ import React from 'react' -import { Link, Router, Routes<% if (isProd) {%>, useDataServer<%}%> } from 'docz' +import { Link, Router, Routes<% if (!isProd) {%>, useDataServer<%}%> } from 'docz' <% if (!isProd) {%>import { hot } from 'react-hot-loader'<%}%> import Theme from '<%- theme %>' @@ -8,7 +8,7 @@ import database from './db.json' <% if (wrapper) {%>import Wrapper from '<%- wrapper %>'<%}%> const Root = () => { - <% if (websocketUrl || isProd) {%>useDataServer('<%- websocketUrl %>')<%}%> + <% if (!isProd && websocketUrl) {%>useDataServer('<%- websocketUrl %>')<%}%> return ( wrapper={Wrapper}<%}%>