recently, when I was reading the official documents of webpack4, I was confused by one thing, that is, the problem of setting environment variables using DefinePlugin. See Code:
import webpack from "webpack";
// `ASSET_PATH`
const ASSET_PATH = process.env.ASSET_PATH || "/";
export default {
output: {
publicPath: ASSET_PATH
},
plugins: [
//
new webpack.DefinePlugin({
"process.env.ASSET_PATH": JSON.stringify(ASSET_PATH)
})
]
};
this is the code on the official website ides/public-path/" rel=" nofollow noreferrer "> this is the link
I would like to ask, above is to assign process.env.ASSET_PATH to ASSET_PATH, and below is to use DefinePlugin to set the value of process.env.ASSET_PATH to aset _ PATH. What does this mean?
there are no great gods, can explain a little easier to understand, thank you!