@@ -11,8 +11,11 @@ import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setu
11
11
12
12
describeBuilder ( buildApplication , APPLICATION_BUILDER_INFO , ( harness ) => {
13
13
beforeEach ( async ( ) => {
14
- // Add a media file
14
+ // Add a global stylesheet media file
15
15
await harness . writeFile ( 'src/styles.css' , `h1 { background: url('./spectrum.png')}` ) ;
16
+ // Add a component stylesheet media file
17
+ await harness . writeFile ( 'src/app/abc.svg' , '' ) ;
18
+ await harness . writeFile ( 'src/app/app.component.css' , `h2 { background: url('./abc.svg')}` ) ;
16
19
17
20
// Enable SSR
18
21
await harness . modifyFile ( 'src/tsconfig.app.json' , ( content ) => {
@@ -23,10 +26,9 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
23
26
return JSON . stringify ( tsConfig ) ;
24
27
} ) ;
25
28
26
- // Application code is not needed in this test
29
+ // Application server code is not needed in this test
27
30
await harness . writeFile ( 'src/main.server.ts' , `console.log('Hello!');` ) ;
28
31
await harness . writeFile ( 'src/server.ts' , `console.log('Hello!');` ) ;
29
- await harness . writeFile ( 'src/main.ts' , `console.log('Hello!');` ) ;
30
32
} ) ;
31
33
32
34
describe ( 'Option: "outputPath"' , ( ) => {
@@ -56,6 +58,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
56
58
expect ( result ?. success ) . toBeTrue ( ) ;
57
59
58
60
harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
61
+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
59
62
} ) ;
60
63
61
64
it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -96,6 +99,50 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
96
99
expect ( result ?. success ) . toBeTrue ( ) ;
97
100
98
101
harness . expectFile ( 'dist/browser/resource/spectrum.png' ) . toExist ( ) ;
102
+ harness . expectFile ( 'dist/browser/resource/abc.svg' ) . toExist ( ) ;
103
+ } ) ;
104
+
105
+ it ( `should emit server bundles in 'server' directory` , async ( ) => {
106
+ const { result } = await harness . executeOnce ( ) ;
107
+ expect ( result ?. success ) . toBeTrue ( ) ;
108
+
109
+ harness . expectFile ( 'dist/server/server.mjs' ) . toExist ( ) ;
110
+ } ) ;
111
+ } ) ;
112
+
113
+ describe ( `'media' is set to ''` , ( ) => {
114
+ beforeEach ( ( ) => {
115
+ harness . useTarget ( 'build' , {
116
+ ...BASE_OPTIONS ,
117
+ polyfills : [ ] ,
118
+ styles : [ 'src/styles.css' ] ,
119
+ server : 'src/main.server.ts' ,
120
+ outputPath : {
121
+ base : 'dist' ,
122
+ media : '' ,
123
+ } ,
124
+ ssr : {
125
+ entry : 'src/server.ts' ,
126
+ } ,
127
+ } ) ;
128
+ } ) ;
129
+
130
+ it ( `should emit browser bundles in 'browser' directory` , async ( ) => {
131
+ const { result } = await harness . executeOnce ( ) ;
132
+ expect ( result ?. success ) . toBeTrue ( ) ;
133
+
134
+ harness . expectFile ( 'dist/browser/main.js' ) . toExist ( ) ;
135
+ } ) ;
136
+
137
+ it ( `should emit media files in 'browser' directory` , async ( ) => {
138
+ const { result } = await harness . executeOnce ( ) ;
139
+ expect ( result ?. success ) . toBeTrue ( ) ;
140
+
141
+ harness . expectFile ( 'dist/browser/spectrum.png' ) . toExist ( ) ;
142
+ harness . expectFile ( 'dist/browser/abc.svg' ) . toExist ( ) ;
143
+
144
+ // Component CSS should not be considered media
145
+ harness . expectFile ( 'dist/browser/app.component.css' ) . toNotExist ( ) ;
99
146
} ) ;
100
147
101
148
it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -135,6 +182,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
135
182
expect ( result ?. success ) . toBeTrue ( ) ;
136
183
137
184
harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
185
+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
138
186
} ) ;
139
187
140
188
it ( `should emit server bundles in 'node-server' directory` , async ( ) => {
@@ -174,6 +222,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
174
222
expect ( result ?. success ) . toBeTrue ( ) ;
175
223
176
224
harness . expectFile ( 'dist/public/media/spectrum.png' ) . toExist ( ) ;
225
+ harness . expectFile ( 'dist/public/media/abc.svg' ) . toExist ( ) ;
177
226
} ) ;
178
227
179
228
it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -220,6 +269,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
220
269
expect ( result ?. success ) . toBeTrue ( ) ;
221
270
222
271
harness . expectFile ( 'dist/media/spectrum.png' ) . toExist ( ) ;
272
+ harness . expectFile ( 'dist/media/abc.svg' ) . toExist ( ) ;
223
273
} ) ;
224
274
225
275
it ( `should error when ssr is enabled` , async ( ) => {
@@ -273,6 +323,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
273
323
expect ( result ?. success ) . toBeTrue ( ) ;
274
324
275
325
harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
326
+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
276
327
} ) ;
277
328
278
329
it ( `should emit server bundles in '' directory` , async ( ) => {
0 commit comments