-
Notifications
You must be signed in to change notification settings - Fork 150
/
Copy pathextra-webpack.config.js
37 lines (33 loc) · 1.04 KB
/
extra-webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Support storing environment variables in a file named "testenv"
const path = require('path');
const dotenv = require('dotenv');
const fs = require('fs');
// Read environment variables from "testenv". Override environment vars if they are already set.
const TESTENV = path.resolve(__dirname, '..', 'testenv');
if (fs.existsSync(TESTENV)) {
const envConfig = dotenv.parse(fs.readFileSync(TESTENV));
Object.keys(envConfig).forEach((k) => {
process.env[k] = envConfig[k];
});
}
process.env.CLIENT_ID = process.env.CLIENT_ID || process.env.SPA_CLIENT_ID;
const webpack = require('webpack');
const env = {};
// List of environment variables made available to the app
[
'ISSUER',
'CLIENT_ID',
].forEach(function (key) {
if (!process.env[key]) {
throw new Error(`Environment variable ${key} must be set. See README.md`);
}
env[key] = JSON.stringify(process.env[key]);
});
// Added to angular's webpack config by @angular-builders/custom-webpack
module.exports = {
plugins: [
new webpack.DefinePlugin({
'process.env': env
})
]
};