Browse Source

build(webpack): remove redundant NODE_ENV setting

Webpack v4 introduced a new `mode` setting, which - amongst other
things - automates the definition of the NODE_ENV environment variable.
We already had the `mode` settings set in our webpack configs so this
change is just to clean up some redundant code that is handled
automatically by this setting.

See:
 - https://webpack.js.org/concepts/mode/
renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
42b08272ec
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 8
      package.json
  2. 7
      webpack.config.base.js
  3. 8
      webpack.config.main.prod.js
  4. 13
      webpack.config.renderer.dev.dll.js
  5. 16
      webpack.config.renderer.dev.js
  6. 14
      webpack.config.renderer.prod.js

8
package.json

@ -5,9 +5,9 @@
"description": "desktop application for the lightning network", "description": "desktop application for the lightning network",
"scripts": { "scripts": {
"build": "concurrently --raw \"npm run build-main\" \"npm run build-renderer\"", "build": "concurrently --raw \"npm run build-main\" \"npm run build-renderer\"",
"build-dll": "cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.dev.dll.js --colors", "build-dll": "node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.dev.dll.js --colors",
"build-main": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.main.prod.js --colors", "build-main": "node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.main.prod.js --colors",
"build-renderer": "cross-env NODE_ENV=production node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.prod.js --colors", "build-renderer": "node --trace-warnings -r babel-register ./node_modules/webpack/bin/webpack --config webpack.config.renderer.prod.js --colors",
"dev": "cross-env START_HOT=1 npm run start-renderer-dev", "dev": "cross-env START_HOT=1 npm run start-renderer-dev",
"flow": "flow", "flow": "flow",
"flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true", "flow-typed": "rimraf flow-typed/npm && flow-typed install --overwrite || true",
@ -28,7 +28,7 @@
"prestart": "npm run build", "prestart": "npm run build",
"start": "cross-env NODE_ENV=production electron ./app/", "start": "cross-env NODE_ENV=production electron ./app/",
"start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev", "start-main-dev": "cross-env HOT=1 NODE_ENV=development electron -r babel-register ./app/main.dev",
"start-renderer-dev": "cross-env NODE_ENV=development node --trace-warnings -r babel-register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack.config.renderer.dev.js", "start-renderer-dev": "node --trace-warnings -r babel-register ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack.config.renderer.dev.js",
"test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js", "test": "cross-env NODE_ENV=test BABEL_DISABLE_CACHE=1 node --trace-warnings ./test/runTests.js",
"test-ci": "npm run package && npm run test && npm run test-e2e", "test-ci": "npm run package && npm run test && npm run test-e2e",
"test-all": "npm run lint && npm run lint-styles && npm run flow && npm run build && npm run test && npm run test-e2e", "test-all": "npm run lint && npm run lint-styles && npm run flow && npm run build && npm run test && npm run test-e2e",

7
webpack.config.base.js

@ -3,7 +3,6 @@
*/ */
import path from 'path' import path from 'path'
import webpack from 'webpack'
import { dependencies as externals } from './app/package.json' import { dependencies as externals } from './app/package.json'
export default { export default {
@ -39,12 +38,6 @@ export default {
modules: [path.join(__dirname, 'app'), 'node_modules'] modules: [path.join(__dirname, 'app'), 'node_modules']
}, },
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
})
],
optimization: { optimization: {
namedModules: true namedModules: true
} }

8
webpack.config.main.prod.js

@ -39,13 +39,9 @@ export default merge.smart(baseConfig, {
* *
* Useful for allowing different behaviour between development builds and * Useful for allowing different behaviour between development builds and
* release builds * release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*/ */
new webpack.DefinePlugin({ new webpack.EnvironmentPlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), DEBUG_PROD: false
'process.env.DEBUG_PROD': JSON.stringify(process.env.DEBUG_PROD || 'false')
}) })
], ],

13
webpack.config.renderer.dev.dll.js

@ -178,19 +178,6 @@ export default merge.smart(baseConfig, {
name: '[name]' name: '[name]'
}), }),
/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new webpack.LoaderOptionsPlugin({ new webpack.LoaderOptionsPlugin({
debug: true, debug: true,
options: { options: {

16
webpack.config.renderer.dev.js

@ -212,22 +212,6 @@ export default merge.smart(baseConfig, {
// multiStep: true // multiStep: true
}), }),
/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*
* By default, use 'development' as NODE_ENV. This can be overriden with
* 'staging', for example, by changing the ENV variables in the npm scripts
*/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
}),
new webpack.LoaderOptionsPlugin({ new webpack.LoaderOptionsPlugin({
debug: true debug: true
}), }),

14
webpack.config.renderer.prod.js

@ -3,7 +3,6 @@
*/ */
import path from 'path' import path from 'path'
import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin' import ExtractTextPlugin from 'extract-text-webpack-plugin'
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer' import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
import merge from 'webpack-merge' import merge from 'webpack-merge'
@ -143,19 +142,6 @@ export default merge.smart(baseConfig, {
}, },
plugins: [ plugins: [
/**
* Create global constants which can be configured at compile time.
*
* Useful for allowing different behaviour between development builds and
* release builds
*
* NODE_ENV should be production so that modules do not perform certain
* development checks
*/
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
}),
new ExtractTextPlugin('style.css'), new ExtractTextPlugin('style.css'),
new BundleAnalyzerPlugin({ new BundleAnalyzerPlugin({

Loading…
Cancel
Save