I need to use .env file in the firebase-messaging-sw.js located at public folder in the ReactJs. The .env file is located in project root folder and I need to use it in the firebase-messaging-sw.js without moving .env to another location. but When the environment variables was called in firebase-messaging-sw.js. I get the the reference error "process is not defined at firebase-messaging-sw.js" in ReactJs
This is my code in the firebase-messaging-sw.js.
importScripts('https://www.gstatic.com/firebasejs/7.8.1/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/7.8.1/firebase-messaging.js');
const config = {
apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID,
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_FIREBASE_APP_ID,
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
Is there an any idea to solve my problem?