I am initiating webpack from a Gruntfile
.
If I have a task like this:
grunt.registerTask('start', ['browser', 'webpack-dev-server'], () => {
// how do I set an environment variable?
});
How can I set some part of env
so that it is accessible in webpack?
If you're executing webpack in your arrow function, you can set the environment variable on process.env
first:
grunt.registerTask('start', ['browser', 'webpack-dev-server'], () => {
process.env.SOME_VARIABLE = // ... some value here
// ... execute webpack
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.