diff --git a/OPTIONS.md b/OPTIONS.md index c41e92ee5f0..4e4c4158bc3 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -10,7 +10,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. diff --git a/SERVE-OPTIONS-v4.md b/SERVE-OPTIONS-v4.md index 4d13e484101..e366b278d42 100644 --- a/SERVE-OPTIONS-v4.md +++ b/SERVE-OPTIONS-v4.md @@ -9,7 +9,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. diff --git a/packages/generators/init-template/default/package.json.js b/packages/generators/init-template/default/package.json.js index 27af3fd3cb8..79d967ebe16 100644 --- a/packages/generators/init-template/default/package.json.js +++ b/packages/generators/init-template/default/package.json.js @@ -1,8 +1,8 @@ module.exports = (isUsingDevServer) => { const scripts = { - build: "webpack --mode=production --define-process-env-node-env=production", + build: "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", watch: "webpack --watch", }; if (isUsingDevServer) { diff --git a/packages/generators/init-template/react/package.json.tpl b/packages/generators/init-template/react/package.json.tpl index 87282af1634..14aebb6b9c7 100644 --- a/packages/generators/init-template/react/package.json.tpl +++ b/packages/generators/init-template/react/package.json.tpl @@ -3,9 +3,9 @@ "description": "My webpack project", "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", "serve": "webpack serve" } diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index bdb0e382a52..430d7f08b46 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -84,7 +84,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 868ffbb9147..72eea48b7df 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -890,7 +890,7 @@ class WebpackCLI implements IWebpackCLI { description: "Environment passed to the configuration when it is a function.", }, { - name: "define-process-env-node-env", + name: "node-env", configs: [ { type: "string", @@ -899,6 +899,17 @@ class WebpackCLI implements IWebpackCLI { multiple: false, description: "Sets process.env.NODE_ENV to the specified value.", }, + { + name: "define-process-env-node-env", + configs: [ + { + type: "string", + }, + ], + multiple: false, + description: + "Sets process.env.NODE_ENV to the specified value. (Currently an alias for `--node-env`)", + }, // Adding more plugins { @@ -2176,7 +2187,10 @@ class WebpackCLI implements IWebpackCLI { callback?: Callback<[Error | undefined, WebpackCLIStats | undefined]>, ): Promise { if (typeof options.defineProcessEnvNodeEnv === "string") { + // TODO: This should only set NODE_ENV for the runtime not for the config too. Change this during next breaking change. process.env.NODE_ENV = options.defineProcessEnvNodeEnv; + } else if (typeof options.nodeEnv === "string") { + process.env.NODE_ENV = options.nodeEnv; } let config = await this.loadConfig(options); diff --git a/test/build/node-env/auto-mode.config.js b/test/build/node-env/auto-mode.config.js new file mode 100644 index 00000000000..f68b5414666 --- /dev/null +++ b/test/build/node-env/auto-mode.config.js @@ -0,0 +1,5 @@ +const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); + +module.exports = { + plugins: [new WebpackCLITestPlugin()], +}; diff --git a/test/build/node-env/node-env.test.js b/test/build/node-env/node-env.test.js new file mode 100644 index 00000000000..35f69d8c94c --- /dev/null +++ b/test/build/node-env/node-env.test.js @@ -0,0 +1,68 @@ +"use strict"; + +const { run } = require("../../utils/test-utils"); + +describe("--node-env flag", () => { + it('should set "process.env.NODE_ENV" to "development"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["--node-env", "development"]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'development'"); + }); + + it('should set "process.env.NODE_ENV" to "production"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["--node-env", "production"]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'production'"); + }); + + it('should set "process.env.NODE_ENV" to "none"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["--node-env", "none"]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'none'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "development"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, [ + "--node-env", + "development", + "--config", + "./auto-mode.config.js", + ]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'development'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "production"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, [ + "--node-env", + "production", + "--config", + "./auto-mode.config.js", + ]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'production'"); + }); + + it('should set "process.env.NODE_ENV" and the "mode" option to "none"', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, [ + "--node-env", + "none", + "--config", + "./auto-mode.config.js", + ]); + + expect(exitCode).toBe(0); + expect(stderr).toBeFalsy(); + expect(stdout).toContain("mode: 'none'"); + }); +}); diff --git a/test/build/node-env/src/index.js b/test/build/node-env/src/index.js new file mode 100644 index 00000000000..c70a2899e94 --- /dev/null +++ b/test/build/node-env/src/index.js @@ -0,0 +1 @@ +console.log('--node-env test'); \ No newline at end of file diff --git a/test/build/node-env/webpack.config.js b/test/build/node-env/webpack.config.js new file mode 100644 index 00000000000..71e8ab21cc3 --- /dev/null +++ b/test/build/node-env/webpack.config.js @@ -0,0 +1,6 @@ +const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin"); + +module.exports = { + mode: process.env.NODE_ENV, + plugins: [new WebpackCLITestPlugin()], +}; diff --git a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 index 44924069518..6bfca3640fc 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer4.webpack5 @@ -99,7 +99,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -158,7 +159,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -217,7 +219,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -275,7 +278,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -321,7 +325,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -367,7 +372,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -413,7 +419,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -459,7 +466,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -505,7 +513,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1485,7 +1494,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1529,7 +1539,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1573,7 +1584,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1617,7 +1629,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1661,7 +1674,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1705,7 +1719,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1750,7 +1765,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -1809,7 +1825,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -2058,7 +2075,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. @@ -2115,7 +2133,8 @@ Options: -m, --merge Merge two or more configurations using 'webpack-merge'. --disable-interpret Disable interpret for loading the config file. --env Environment passed to the configuration when it is a function. - --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. + --node-env Sets process.env.NODE_ENV to the specified value. + --define-process-env-node-env Sets process.env.NODE_ENV to the specified value. (Currently an alias for \`--node-env\`) --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. -j, --json [value] Prints result as JSON or store it in a file. diff --git a/test/init/__snapshots__/init.test.js.snap.webpack5 b/test/init/__snapshots__/init.test.js.snap.webpack5 index 46de4d0828d..d82c4e97b1c 100644 --- a/test/init/__snapshots__/init.test.js.snap.webpack5 +++ b/test/init/__snapshots__/init.test.js.snap.webpack5 @@ -12,9 +12,9 @@ exports[`init command recognizes '-f' as an alias for '--force' 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -34,9 +34,9 @@ exports[`init command recognizes '-t' as an alias for '--template' 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -56,9 +56,9 @@ exports[`init command should ask question when wrong template is supplied 1`] = }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -76,9 +76,9 @@ exports[`init command should configure WDS as opted 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -142,9 +142,9 @@ exports[`init command should configure assets modules by default 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -214,9 +214,9 @@ exports[`init command should configure html-webpack-plugin as opted 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -279,9 +279,9 @@ exports[`init command should configure workbox-webpack-plugin as opted 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -348,9 +348,9 @@ exports[`init command should generate ES6 project correctly 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -413,9 +413,9 @@ exports[`init command should generate default project when nothing is passed 1`] }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -435,9 +435,9 @@ exports[`init command should generate folders if non existing generation path is }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -457,9 +457,9 @@ exports[`init command should generate project when generationPath is supplied 1` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -485,9 +485,9 @@ exports[`init command should generate react template with --force 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -574,9 +574,9 @@ exports[`init command should generate react template with prompt answers 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -647,9 +647,9 @@ exports[`init command should generate typescript project correctly 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -717,9 +717,9 @@ exports[`init command should use less in project when selected 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -785,9 +785,9 @@ exports[`init command should use mini-css-extract-plugin when selected 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -854,9 +854,9 @@ exports[`init command should use postcss in project when selected 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -925,9 +925,9 @@ exports[`init command should use sass and css with postcss in project when selec }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -997,9 +997,9 @@ exports[`init command should use sass in project when selected 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -1068,9 +1068,9 @@ exports[`init command should use sass with postcss in project when selected 1`] }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -1136,9 +1136,9 @@ exports[`init command should use stylus in project when selected 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0", @@ -1203,9 +1203,9 @@ exports[`init command should work with 'c' alias 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -1225,9 +1225,9 @@ exports[`init command should work with 'create' alias 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -1247,9 +1247,9 @@ exports[`init command should work with 'n' alias 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -1269,9 +1269,9 @@ exports[`init command should work with 'new' alias 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "serve": "webpack serve", "watch": "webpack --watch", }, @@ -1288,9 +1288,9 @@ exports[`init command uses yarn as the package manager when opted 1`] = ` }, "name": "my-webpack-project", "scripts": { - "build": "webpack --mode=production --define-process-env-node-env=production", + "build": "webpack --mode=production --node-env=production", "build:dev": "webpack --mode=development", - "build:prod": "webpack --mode=production --define-process-env-node-env=production", + "build:prod": "webpack --mode=production --node-env=production", "watch": "webpack --watch", }, "version": "1.0.0",