Skip to content

Commit 226603f

Browse files
Ismael Ramosiramos
authored andcommitted
feat(angular9): fix ssr
1 parent c1937f0 commit 226603f

18 files changed

+321
-562
lines changed

angular.json

Lines changed: 122 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"i18n": {
88
"locales": {
99
"en": {
10-
"translation": "src/i18n/messages.en.xlf",
10+
"translation": "src/i18n/messages.xlf",
1111
"baseHref": "/"
1212
},
1313
"es": "src/i18n/messages.es.xlf"
@@ -26,11 +26,28 @@
2626
"build": {
2727
"builder": "@angular-devkit/build-angular:browser",
2828
"options": {
29+
"outputPath": "dist/browser/en/",
2930
"index": "src/index.html",
3031
"main": "src/main.browser.ts",
3132
"polyfills": "src/polyfills.ts",
32-
"tsConfig": "tsconfig.app.json",
33-
"aot": true,
33+
"tsConfig": "tsconfig.browser.json",
34+
"assets": [
35+
{
36+
"glob": "**/*",
37+
"input": "src/assets/",
38+
"output": "/assets/",
39+
"ignore": [
40+
"base/*",
41+
"css/*",
42+
"js/*"
43+
]
44+
},
45+
{
46+
"glob": "**/*",
47+
"input": "src/assets/base",
48+
"output": "/"
49+
}
50+
],
3451
"styles": [
3552
"node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css",
3653
"src/assets/css/reset.css",
@@ -47,86 +64,21 @@
4764
"src/assets/js/modernizr.js"
4865
],
4966
"serviceWorker": true,
50-
"ngswConfigPath": "src/ngsw-config.json"
67+
"ngswConfigPath": "src/ngsw-config.json",
68+
"budgets": [
69+
{
70+
"type": "anyComponentStyle",
71+
"maximumWarning": "6kb"
72+
},
73+
{
74+
"type": "initial",
75+
"maximumWarning": "2mb",
76+
"maximumError": "5mb"
77+
}
78+
]
5179
},
5280
"configurations": {
53-
"en": {
54-
"budgets": [
55-
{
56-
"type": "anyComponentStyle",
57-
"maximumWarning": "6kb"
58-
}
59-
],
60-
"outputPath": "dist/browser/",
61-
"i18nFile": "src/i18n/messages.en.xlf",
62-
"i18nLocale": "en",
63-
"i18nMissingTranslation": "error",
64-
"assets": [
65-
{
66-
"glob": "**/*",
67-
"input": "src/assets/",
68-
"output": "/assets/",
69-
"ignore": [
70-
"base/*",
71-
"css/*",
72-
"js/*"
73-
]
74-
},
75-
{
76-
"glob": "**/*",
77-
"input": "src/assets/base",
78-
"output": "/"
79-
}
80-
]
81-
},
82-
"es": {
83-
"budgets": [
84-
{
85-
"type": "anyComponentStyle",
86-
"maximumWarning": "6kb"
87-
}
88-
],
89-
"localize": [
90-
"es"
91-
],
92-
"outputPath": "dist/browser",
93-
"i18nMissingTranslation": "error",
94-
"assets": [
95-
{
96-
"glob": "**/*",
97-
"input": "src/assets/",
98-
"output": "/assets/",
99-
"ignore": [
100-
"base/*",
101-
"css/*",
102-
"js/*"
103-
]
104-
},
105-
{
106-
"glob": "**/*",
107-
"input": "src/assets/base",
108-
"output": "/"
109-
}
110-
]
111-
},
112-
"production-en": {
113-
"assets": [
114-
{
115-
"glob": "**/*",
116-
"input": "src/assets/",
117-
"output": "/assets/",
118-
"ignore": [
119-
"base/*",
120-
"css/*",
121-
"js/*"
122-
]
123-
},
124-
{
125-
"glob": "**/*",
126-
"input": "src/assets/base",
127-
"output": "/"
128-
}
129-
],
81+
"production": {
13082
"fileReplacements": [
13183
{
13284
"replace": "src/environments/environment.ts",
@@ -138,69 +90,120 @@
13890
"sourceMap": false,
13991
"extractCss": true,
14092
"namedChunks": false,
93+
"aot": true,
14194
"extractLicenses": true,
14295
"vendorChunk": false,
143-
"buildOptimizer": true,
144-
"budgets": [
145-
{
146-
"type": "anyComponentStyle",
147-
"maximumWarning": "6kb"
148-
}
149-
],
150-
"outputPath": "dist/browser/",
151-
"i18nFile": "src/i18n/messages.en.xlf",
152-
"i18nLocale": "en",
153-
"i18nMissingTranslation": "error"
96+
"buildOptimizer": true
15497
},
15598
"production-es": {
99+
"baseHref": "/es/",
156100
"fileReplacements": [
157101
{
158102
"replace": "src/environments/environment.ts",
159103
"with": "src/environments/environment.prod.ts"
160104
}
161105
],
162-
"localize": [
163-
"es"
164-
],
165106
"optimization": true,
166107
"outputHashing": "all",
167108
"sourceMap": false,
168109
"extractCss": true,
169110
"namedChunks": false,
111+
"aot": true,
170112
"extractLicenses": true,
171113
"vendorChunk": false,
172114
"buildOptimizer": true,
173-
"budgets": [
174-
{
175-
"type": "anyComponentStyle",
176-
"maximumWarning": "6kb"
177-
}
178-
],
179-
"outputPath": "dist/browser",
115+
"outputPath": "dist/browser/es/",
116+
"i18nFile": "src/locale/messages.es.xlf",
117+
"i18nFormat": "xlf",
118+
"i18nLocale": "es",
119+
"i18nMissingTranslation": "error"
120+
},
121+
"es": {
122+
"baseHref": "/es/",
123+
"aot": true,
124+
"outputPath": "dist/browser/es/",
125+
"i18nFile": "src/locale/messages.es.xlf",
126+
"i18nFormat": "xlf",
127+
"i18nLocale": "es",
180128
"i18nMissingTranslation": "error"
181129
}
182130
}
183131
},
184132
"serve": {
185133
"builder": "@angular-devkit/build-angular:dev-server",
186134
"options": {
187-
"browserTarget": "angularexampleapp:build:en"
135+
"browserTarget": "angularexampleapp:build"
188136
},
189137
"configurations": {
190-
"en": {
191-
"browserTarget": "angularexampleapp:build:en"
138+
"production": {
139+
"browserTarget": "angularexampleapp:build:production"
192140
},
193141
"es": {
194142
"browserTarget": "angularexampleapp:build:es"
195143
}
196144
}
197145
},
146+
"serve-ssr": {
147+
"builder": "@nguniversal/builders:ssr-dev-server",
148+
"options": {
149+
"browserTarget": "angularexampleapp:build",
150+
"serverTarget": "angularexampleapp:server"
151+
},
152+
"configurations": {
153+
"production": {
154+
"browserTarget": "angularexampleapp:build:production",
155+
"serverTarget": "angularexampleapp:server:production"
156+
}
157+
}
158+
},
159+
"server": {
160+
"builder": "@angular-devkit/build-angular:server",
161+
"options": {
162+
"outputPath": "dist/server",
163+
"main": "server.ts",
164+
"tsConfig": "./tsconfig.server.json",
165+
"stylePreprocessorOptions": {
166+
"includePaths": [
167+
"src/styles"
168+
]
169+
},
170+
"externalDependencies": [
171+
"@firebase/firestore"
172+
]
173+
},
174+
"configurations": {
175+
"production": {
176+
"optimization": true,
177+
"fileReplacements": [
178+
{
179+
"replace": "src/environments/environment.ts",
180+
"with": "src/environments/environment.prod.ts"
181+
}
182+
]
183+
}
184+
}
185+
},
198186
"extract-i18n": {
199187
"builder": "@angular-devkit/build-angular:extract-i18n",
200188
"options": {
201189
"browserTarget": "angularexampleapp:build"
202190
}
203191
},
192+
"xliffmerge": {
193+
"builder": "@ngx-i18nsupport/tooling:xliffmerge",
194+
"options": {
195+
"xliffmergeOptions": {
196+
"i18nFormat": "xlf",
197+
"srcDir": "src/i18n",
198+
"genDir": "src/i18n",
199+
"defaultLanguage": "en",
200+
"languages": [
201+
"en",
202+
"es"
203+
]
204+
}
205+
}
206+
},
204207
"test": {
205208
"builder": "@angular-devkit/build-angular:karma",
206209
"options": {
@@ -233,7 +236,7 @@
233236
"builder": "@angular-devkit/build-angular:tslint",
234237
"options": {
235238
"tsConfig": [
236-
"tsconfig.app.json",
239+
"tsconfig.browser.json",
237240
"tsconfig.spec.json",
238241
"e2e/tsconfig.json"
239242
],
@@ -242,63 +245,6 @@
242245
]
243246
}
244247
},
245-
"server": {
246-
"builder": "@angular-devkit/build-angular:server",
247-
"options": {
248-
"main": "src/main.server.ts",
249-
"tsConfig": "tsconfig.server.json",
250-
"stylePreprocessorOptions": {
251-
"includePaths": [
252-
"src/app/shared/styles"
253-
]
254-
}
255-
},
256-
"configurations": {
257-
"production-en": {
258-
"optimization": true,
259-
"outputPath": "dist/server/en",
260-
"i18nFile": "src/i18n/messages.en.xlf",
261-
"i18nFormat": "xlf",
262-
"i18nLocale": "en",
263-
"i18nMissingTranslation": "error",
264-
"fileReplacements": [
265-
{
266-
"replace": "src/environments/environment.ts",
267-
"with": "src/environments/environment.prod.ts"
268-
}
269-
]
270-
},
271-
"production-es": {
272-
"optimization": true,
273-
"outputPath": "dist/server/es",
274-
"i18nFile": "src/i18n/messages.es.xlf",
275-
"i18nFormat": "xlf",
276-
"i18nLocale": "es",
277-
"i18nMissingTranslation": "error",
278-
"fileReplacements": [
279-
{
280-
"replace": "src/environments/environment.ts",
281-
"with": "src/environments/environment.prod.ts"
282-
}
283-
]
284-
}
285-
}
286-
},
287-
"xliffmerge": {
288-
"builder": "@ngx-i18nsupport/tooling:xliffmerge",
289-
"options": {
290-
"xliffmergeOptions": {
291-
"i18nFormat": "xlf",
292-
"srcDir": "src/i18n",
293-
"genDir": "src/i18n",
294-
"defaultLanguage": "en",
295-
"languages": [
296-
"en",
297-
"es"
298-
]
299-
}
300-
}
301-
},
302248
"e2e": {
303249
"builder": "@angular-devkit/build-angular:protractor",
304250
"options": {
@@ -310,6 +256,19 @@
310256
"devServerTarget": "angularexampleapp:serve:production"
311257
}
312258
}
259+
},
260+
"prerender": {
261+
"builder": "@nguniversal/builders:prerender",
262+
"options": {
263+
"browserTarget": "angularexampleapp:build:production",
264+
"serverTarget": "angularexampleapp:server:production",
265+
"routes": [
266+
"/"
267+
]
268+
},
269+
"configurations": {
270+
"production": {}
271+
}
313272
}
314273
}
315274
},

0 commit comments

Comments
 (0)