Skip to content

Commit

Permalink
feat: enable react devtools in plugin builds
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Feb 15, 2024
1 parent 0c8bf22 commit c2d1776
Show file tree
Hide file tree
Showing 3 changed files with 476 additions and 8 deletions.
14 changes: 13 additions & 1 deletion cli/config/plugin.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ module.exports = ({ env: webpackEnv, config, paths, pluginifiedApp }) => {
].filter(Boolean)
}

// DHIS2
// .d2/shell/src/index.js or .../plugin.index.js
const entry = pluginifiedApp
? paths.shellAppBundleEntrypoint
Expand All @@ -109,10 +110,21 @@ module.exports = ({ env: webpackEnv, config, paths, pluginifiedApp }) => {

const outputFilenamePrefix = pluginifiedApp ? 'app' : 'plugin'

// DHIS2
// in dev (using process.env.NODE_ENV because `isProduction` is currently
// hard-coded to 'true' as a workaround), add 'react-devtools' to the entry
// to enabled standalone React Dev Tools to work in iframes
// Intro: https://stackoverflow.com/a/71513012
// https://github.com/facebook/react/tree/main/packages/react-devtools#usage-with-react-dom
const resolvedEntry =
process.env.NODE_ENV === 'development'
? ['react-devtools', entry]
: entry

return {
mode: webpackEnv,
bail: isProduction,
entry: entry,
entry: resolvedEntry,
output: {
path: paths.shellBuildOutput,
filename: isProduction
Expand Down
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"parse-gitignore": "^1.0.1",
"postcss-loader": "^7.0.1",
"react-dev-utils": "^12.0.0",
"react-devtools": "^5.0.0",
"react-refresh": "^0.11.0",
"style-loader": "^3.3.1",
"styled-jsx": "^4.0.1",
Expand Down
Loading

0 comments on commit c2d1776

Please sign in to comment.