Skip to content

Commit 740e3ab

Browse files
committed
added custom webpack config to pass os environment variables to angular
1 parent d63c5e6 commit 740e3ab

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

Diff for: angular.json

+11-23
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
"schematics": {},
1212
"architect": {
1313
"build": {
14-
"builder": "@angular-devkit/build-angular:browser",
14+
"builder": "@angular-builders/custom-webpack:browser",
1515
"options": {
16+
"customWebpackConfig": {
17+
"path": "custom-webpack.config.js"
18+
},
1619
"outputPath": "dist/angular-docker-environment-variables",
1720
"index": "src/index.html",
1821
"main": "src/main.ts",
1922
"polyfills": "src/polyfills.ts",
2023
"tsConfig": "src/tsconfig.app.json",
21-
"assets": [
22-
"src/favicon.ico",
23-
"src/assets"
24-
],
24+
"assets": ["src/favicon.ico", "src/assets"],
2525
"styles": [
2626
"src/styles.css",
2727
"node_modules/bootstrap/dist/css/bootstrap.css"
@@ -79,26 +79,16 @@
7979
"polyfills": "src/polyfills.ts",
8080
"tsConfig": "src/tsconfig.spec.json",
8181
"karmaConfig": "src/karma.conf.js",
82-
"styles": [
83-
"src/styles.css"
84-
],
82+
"styles": ["src/styles.css"],
8583
"scripts": [],
86-
"assets": [
87-
"src/favicon.ico",
88-
"src/assets"
89-
]
84+
"assets": ["src/favicon.ico", "src/assets"]
9085
}
9186
},
9287
"lint": {
9388
"builder": "@angular-devkit/build-angular:tslint",
9489
"options": {
95-
"tsConfig": [
96-
"src/tsconfig.app.json",
97-
"src/tsconfig.spec.json"
98-
],
99-
"exclude": [
100-
"**/node_modules/**"
101-
]
90+
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
91+
"exclude": ["**/node_modules/**"]
10292
}
10393
}
10494
}
@@ -124,13 +114,11 @@
124114
"builder": "@angular-devkit/build-angular:tslint",
125115
"options": {
126116
"tsConfig": "e2e/tsconfig.e2e.json",
127-
"exclude": [
128-
"**/node_modules/**"
129-
]
117+
"exclude": ["**/node_modules/**"]
130118
}
131119
}
132120
}
133121
}
134122
},
135123
"defaultProject": "angular-docker-environment-variables"
136-
}
124+
}

Diff for: custom-webpack.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const webpack = require('webpack');
2+
3+
module.exports = {
4+
plugins: [
5+
new webpack.DefinePlugin({
6+
$ENV: {
7+
ENVIRONMENT: JSON.stringify(process.env.ENVIRONMENT),
8+
SomeAPIKey: JSON.stringify(process.env.SomeAPIKey),
9+
SomeOtherAPIKey: JSON.stringify(process.env.SomeOtherAPIKey)
10+
}
11+
})
12+
]
13+
};

0 commit comments

Comments
 (0)