Skip to content

Commit

Permalink
fix(cli): fix envs to fix plugins in dev (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Mar 22, 2023
1 parent 5622d0c commit ba29cea
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
6 changes: 4 additions & 2 deletions cli/config/plugin.webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ module.exports = ({ env: webpackEnv, config, paths }) => {
}),
// dhis2: Inject plugin static assets to the existing SW's precache
// manifest. Don't need to do in dev because precaching isn't done
// in dev environments
isProduction &&
// in dev environments.
// Check the actual NODE_ENV because `isProduction` is currently
// always true due to a bug (see src/lib/plugin/start.js)
process.env.NODE_ENV === 'production' &&
new WorkboxWebpackPlugin.InjectManifest({
swSrc: paths.shellBuildServiceWorker,
injectionPoint: 'self.__WB_PLUGIN_MANIFEST',
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const handler = async ({
const paths = makePaths(cwd)

mode = mode || (dev && 'development') || getNodeEnv() || 'production'
process.env.BABEL_ENV = process.env.NODE_ENV = mode
loadEnvFiles(paths, mode)

reporter.print(chalk.green.bold('Build parameters:'))
Expand Down
1 change: 1 addition & 0 deletions cli/src/commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const handler = async ({
const paths = makePaths(cwd)

const mode = 'development'
process.env.BABEL_ENV = process.env.NODE_ENV = mode
loadEnvFiles(paths, mode)

const config = parseConfig(paths)
Expand Down
4 changes: 0 additions & 4 deletions cli/src/lib/plugin/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Based on CRA build script

// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'production'
process.env.NODE_ENV = 'production'

const { reporter } = require('@dhis2/cli-helpers-engine')
const webpack = require('webpack')
const webpackConfigFactory = require('../../../config/plugin.webpack.config')
Expand Down
4 changes: 0 additions & 4 deletions cli/src/lib/plugin/start.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Based on CRA start script

// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development'
process.env.NODE_ENV = 'development'

const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath')
const webpack = require('webpack')
const WebpackDevServer = require('webpack-dev-server')
Expand Down

0 comments on commit ba29cea

Please sign in to comment.