Skip to content

Commit bc83157

Browse files
author
dushyant
committedNov 14, 2018
Using vue config to extend the define plugin definition
1 parent ec51355 commit bc83157

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed
 

‎src/store.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ Vue.use(Vuex);
66

77
// firebase config.
88
firebase.initializeApp({
9-
apiKey: process.env.API_KEY,
10-
authDomain: process.env.AUTH_DOMAIN,
11-
databaseURL: process.env.DB_URL,
12-
projectId: process.env.PROJECT_ID,
13-
storageBucket: process.env.STORAGE_BUCKET,
14-
messagingSenderId: process.env.MESSAGING_SENDER_ID,
9+
apiKey: API_KEY,
10+
authDomain: AUTH_DOMAIN,
11+
databaseURL: DB_URL,
12+
projectId: PROJECT_ID,
13+
storageBucket: STORAGE_BUCKET,
14+
messagingSenderId: MESSAGING_SENDER_ID,
1515
});
1616

1717
const DATABASE = 'todo-list';

‎vue.config.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// vue.config.js
2+
module.exports = {
3+
chainWebpack: config => {
4+
config
5+
.plugin('define')
6+
.tap(options => {
7+
const newOptions = options;
8+
let existingDefs = newOptions.pop();
9+
existingDefs = Object.assign(existingDefs, {
10+
API_KEY: JSON.stringify(process.env.API_KEY),
11+
AUTH_DOMAIN: JSON.stringify(process.env.AUTH_DOMAIN),
12+
DB_URL: JSON.stringify(process.env.DB_URL),
13+
PROJECT_ID: JSON.stringify(process.env.PROJECT_ID),
14+
STORAGE_BUCKET: JSON.stringify(process.env.STORAGE_BUCKET),
15+
MESSAGING_SENDER_ID: JSON.stringify(process.env.MESSAGING_SENDER_ID),
16+
});
17+
newOptions.push(existingDefs);
18+
19+
return newOptions;
20+
})
21+
},
22+
};

0 commit comments

Comments
 (0)