1234567891011121314151617 |
- const webpack = require('webpack')
- const dotenv = require('dotenv')
- module.exports = () =>{
- //获取环境变量配置文件
- const env = dotenv.config().parsed
- //创建一个包含自定义环境变量的插件
- const envKeys =Object.keys(env).reduce((prev, next) =>{
- prev[`process.env.${next}`] = JSON.stringify(env[next])
- return prev
- },{})
- return {
- plugins: [
- new webpack.DefinePlugin(envKeys)
- ]
- }
- }
|