admin管理员组文章数量:1290938
I have a .env
file that contains the NODE_ENV
variable. Per default, it is set to development
. When building the React app with webpack, I launch the mand yarn build
:
"scripts": {
"start": "NODE_ENV=development webpack serve --open --hot",
"build": "NODE_ENV=production && webpack",
}
The .env
file is:
NODE_ENV = "development"
But when logging the NODE_ENV
value in my webpack configuration file, I can see it is still in development
. The build is not minified either. But when I write production
in my .env
file, everything works fine.
The webpack configuration is:
/* eslint-env node */
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const Dotenv = require("dotenv-webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const isProductionMode = (mode) => mode === "production";
module.exports = () => {
const env = require("dotenv").config({ path: __dirname + "/.env" });
const nodeEnv = env.parsed.NODE_ENV;
console.log("
本文标签:
javascriptHow to change NODEENV when building app with webpackStack Overflow
版权声明:本文标题:javascript - How to change NODE_ENV when building app with webpack? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1741503726a2382197.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论