Browse Source

build(webpack): remove redundant environment check

Webpack environment `mode` is defined directly in our environment
specific webpack config files. Due to this, we no longer need to
manually set `NODE_ENV` or check to ensure that it has been set.

See:
 - https://webpack.js.org/concepts/mode/
renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
3e60d518b2
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 12
      internals/scripts/CheckNodeEnv.js
  2. 3
      webpack.config.main.prod.js
  3. 3
      webpack.config.renderer.dev.dll.js
  4. 3
      webpack.config.renderer.dev.js
  5. 3
      webpack.config.renderer.prod.js

12
internals/scripts/CheckNodeEnv.js

@ -1,12 +0,0 @@
// @flow
import chalk from 'chalk'
export default function CheckNodeEnv(expectedEnv: string) {
if (!expectedEnv) {
throw new Error('"expectedEnv" not set')
}
if (process.env.NODE_ENV !== expectedEnv) {
throw new Error(chalk.whiteBright.bgRed.bold(`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`))
}
}

3
webpack.config.main.prod.js

@ -6,9 +6,6 @@ import webpack from 'webpack'
import merge from 'webpack-merge'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('production')
export default merge.smart(baseConfig, {
devtool: 'source-map',

3
webpack.config.renderer.dev.dll.js

@ -7,9 +7,6 @@ import path from 'path'
import merge from 'webpack-merge'
import baseConfig from './webpack.config.base'
import { dependencies } from './package.json'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('development')
const dist = path.resolve(process.cwd(), 'dll')

3
webpack.config.renderer.dev.js

@ -14,11 +14,8 @@ import merge from 'webpack-merge'
import { spawn, execSync } from 'child_process'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
import { mainLog } from './app/utils/log'
CheckNodeEnv('development')
const port = process.env.PORT || 1212
const publicPath = `http://localhost:${port}/dist`
const dll = path.resolve(process.cwd(), 'dll')

3
webpack.config.renderer.prod.js

@ -7,9 +7,6 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import merge from 'webpack-merge'
import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('production')
export default merge.smart(baseConfig, {
devtool: 'source-map',

Loading…
Cancel
Save