Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): remove dev things from prod build
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Mar 13, 2019
1 parent 887d34a commit 3f5b5d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions core/docz-core/src/bundler/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {

config
.entry('app')
.add(require.resolve('react-dev-utils/webpackHotDevClient'))
.when(!isProd, entry =>
entry.add(require.resolve('react-dev-utils/webpackHotDevClient'))
)
.add(paths.indexJs)

/**
Expand Down Expand Up @@ -134,7 +136,7 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
plugins.assets(config, args, env)
plugins.ignore(config)
plugins.injections(config, args, env)
plugins.hot(config)
isProd && plugins.hot(config)

config.when(debug, cfg => plugins.analyzer(cfg))
config.when(!isProd, cfg => plugins.watchNodeModulesPlugin(cfg))
Expand Down Expand Up @@ -178,6 +180,5 @@ export const createConfig = (args: Args, env: Env) => async (hooks: Hooks) => {
config.when(isProd, cfg => minifier(cfg, args))
hooks.onCreateWebpackChain<Config>(config, !isProd, args)
args.onCreateWebpackChain<Config>(config, !isProd, args)

return config.toConfig() as Configuration
}
5 changes: 3 additions & 2 deletions core/docz-core/templates/root.tpl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Link, Router, Routes, useDataServer } from 'docz'
import { hot } from 'react-hot-loader'
<% if (!isProd) {%>import { hot } from 'react-hot-loader'<%}%>
import Theme from '<%- theme %>'

import { imports } from './imports'
Expand All @@ -20,4 +20,5 @@ const Root = () => {
)
}

export default hot(module)(Root)
<% if (!isProd) {%>export default hot(module)(Root)<%}%>
<% if (isProd) {%>export default Root<%}%>

0 comments on commit 3f5b5d7

Please sign in to comment.