CARVIEW |
Select Language
HTTP/2 200
date: Wed, 30 Jul 2025 15:46:26 GMT
content-type: text/html; charset=utf-8
content-length: 11835
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
server: cloudflare
last-modified: Wed, 30 Jul 2025 00:11:08 GMT
access-control-allow-origin: *
etag: W/"6889631c-f9d4"
expires: Wed, 30 Jul 2025 15:56:26 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 803B:13BDA9:26D3C:2BC7A:688A3E51
accept-ranges: bytes
age: 0
via: 1.1 varnish
x-served-by: cache-maa10221-MAA
x-cache: MISS
x-cache-hits: 0
x-timer: S1753890386.184041,VS0,VE228
vary: Accept-Encoding
x-fastly-request-id: 2b4d0f7c396ddee0a772cca5be85b9e9af9c2975
cf-cache-status: DYNAMIC
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=yxSgt6Wq%2F8SHP91F6YZg1G5m0nhYSGAyCL6Ul8Jaj9b%2FN6I9blKZ5QwW2fuYFwpz8xRlWxNRz0T1MjeUkUvYzFd37CJoTZqvkCu2XZc%3D"}]}
cf-ray: 9675fd216d6cc1bd-BLR
Environment Variables | webpack
Environment Variables
To disambiguate in your webpack.config.js
between development and production builds you may use environment variables.
The webpack command line environment option --env
allows you to pass in as many environment variables as you like. Environment variables will be made accessible in your webpack.config.js
. For example, --env production
or --env goal=local
.
npx webpack --env goal=local --env production --progress
There is one change that you will have to make to your webpack config. Typically, module.exports
points to the configuration object. To use the env
variable, you must convert module.exports
to a function:
webpack.config.js
const path = require('path');
module.exports = (env) => {
// Use env.<YOUR VARIABLE> here:
console.log('Goal: ', env.goal); // 'local'
console.log('Production: ', env.production); // true
return {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};
};
« Previous
Authoring LibrariesNext »
Build Performance