How to build external modules with .env from proyect

webpack

#1

Hi guys! I’m creating external modules for vue apps, i am having a problem to access process.env from this modules because when i want to, process.env is empty.
I,m building this modules with webpack and i wander if i can build this modules dynamically, that the external module take the env vars from .env of the project in which is imported.
I tried with webpack-dotenv without success


const Dotenv = require('dotenv-webpack');

    plugins: [
        new Dotenv( {
      		path: '/home/user/app/.env.local'
	} ),
    ],

I don’t know if i am doing right either…
Thanks!


#2

Take a look at this documentation:
https://cli.vuejs.org/guide/mode-and-env.html