@@ -11,8 +11,11 @@ import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setu
1111
1212describeBuilder ( buildApplication , APPLICATION_BUILDER_INFO , ( harness ) => {
1313 beforeEach ( async ( ) => {
14- // Add a media file
14+ // Add a global stylesheet media file
1515 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')}` ) ;
1619
1720 // Enable SSR
1821 await harness . modifyFile ( 'src/tsconfig.app.json' , ( content ) => {
@@ -23,10 +26,9 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
2326 return JSON . stringify ( tsConfig ) ;
2427 } ) ;
2528
26- // Application code is not needed in this test
29+ // Application server code is not needed in this test
2730 await harness . writeFile ( 'src/main.server.ts' , `console.log('Hello!');` ) ;
2831 await harness . writeFile ( 'src/server.ts' , `console.log('Hello!');` ) ;
29- await harness . writeFile ( 'src/main.ts' , `console.log('Hello!');` ) ;
3032 } ) ;
3133
3234 describe ( 'Option: "outputPath"' , ( ) => {
@@ -56,6 +58,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
5658 expect ( result ?. success ) . toBeTrue ( ) ;
5759
5860 harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
61+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
5962 } ) ;
6063
6164 it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -96,6 +99,50 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
9699 expect ( result ?. success ) . toBeTrue ( ) ;
97100
98101 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 ( ) ;
99146 } ) ;
100147
101148 it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -135,6 +182,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
135182 expect ( result ?. success ) . toBeTrue ( ) ;
136183
137184 harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
185+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
138186 } ) ;
139187
140188 it ( `should emit server bundles in 'node-server' directory` , async ( ) => {
@@ -174,6 +222,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
174222 expect ( result ?. success ) . toBeTrue ( ) ;
175223
176224 harness . expectFile ( 'dist/public/media/spectrum.png' ) . toExist ( ) ;
225+ harness . expectFile ( 'dist/public/media/abc.svg' ) . toExist ( ) ;
177226 } ) ;
178227
179228 it ( `should emit server bundles in 'server' directory` , async ( ) => {
@@ -220,6 +269,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
220269 expect ( result ?. success ) . toBeTrue ( ) ;
221270
222271 harness . expectFile ( 'dist/media/spectrum.png' ) . toExist ( ) ;
272+ harness . expectFile ( 'dist/media/abc.svg' ) . toExist ( ) ;
223273 } ) ;
224274
225275 it ( `should error when ssr is enabled` , async ( ) => {
@@ -273,6 +323,7 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
273323 expect ( result ?. success ) . toBeTrue ( ) ;
274324
275325 harness . expectFile ( 'dist/browser/media/spectrum.png' ) . toExist ( ) ;
326+ harness . expectFile ( 'dist/browser/media/abc.svg' ) . toExist ( ) ;
276327 } ) ;
277328
278329 it ( `should emit server bundles in '' directory` , async ( ) => {
0 commit comments