File tree 2 files changed +39
-5
lines changed
packages/angular-cli/tasks
2 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ export default Task.extend({
19
19
const ui = this . ui ;
20
20
21
21
let webpackCompiler : any ;
22
+ const projectConfig = CliConfig . fromProject ( ) . config ;
23
+ const appConfig = projectConfig . apps [ 0 ] ;
22
24
23
25
let config = new NgCliWebpackConfig (
24
26
this . project ,
@@ -84,12 +86,10 @@ export default Task.extend({
84
86
}
85
87
86
88
const webpackDevServerConfiguration : IWebpackDevServerConfigurationOptions = {
87
- contentBase : path . resolve (
88
- this . project . root ,
89
- `./${ CliConfig . fromProject ( ) . config . apps [ 0 ] . root } `
90
- ) ,
89
+ contentBase : path . resolve ( this . project . root , `./${ appConfig . root } ` ) ,
91
90
headers : { 'Access-Control-Allow-Origin' : '*' } ,
92
91
historyApiFallback : {
92
+ index : `/${ appConfig . index } ` ,
93
93
disableDotRule : true ,
94
94
htmlAcceptHeaders : [ 'text/html' , 'application/xhtml+xml' ]
95
95
} ,
@@ -98,7 +98,7 @@ export default Task.extend({
98
98
proxy : proxyConfig ,
99
99
compress : serveTaskOptions . target === 'production' ,
100
100
watchOptions : {
101
- poll : CliConfig . fromProject ( ) . config . defaults . poll
101
+ poll : projectConfig . defaults . poll
102
102
} ,
103
103
https : serveTaskOptions . ssl
104
104
} ;
Original file line number Diff line number Diff line change
1
+ import { request } from '../../utils/http' ;
2
+ import { killAllProcesses } from '../../utils/process' ;
3
+ import { ngServe } from '../../utils/project' ;
4
+ import { updateJsonFile } from '../../utils/project' ;
5
+ import { moveFile } from '../../utils/fs' ;
6
+
7
+
8
+ export default function ( ) {
9
+ // should fallback to config.app[0].index (index.html by default)
10
+ return Promise . resolve ( )
11
+ . then ( ( ) => ngServe ( ) )
12
+ . then ( ( ) => request ( 'http://localhost:4200/' ) )
13
+ . then ( body => {
14
+ if ( ! body . match ( / < a p p - r o o t > L o a d i n g ...< \/ a p p - r o o t > / ) ) {
15
+ throw new Error ( 'Response does not match expected value.' ) ;
16
+ }
17
+ } )
18
+ . then ( ( ) => killAllProcesses ( ) , ( err ) => { killAllProcesses ( ) ; throw err ; } )
19
+ // should correctly fallback to a changed index
20
+ . then ( ( ) => moveFile ( 'src/index.html' , 'src/not-index.html' ) )
21
+ . then ( ( ) => updateJsonFile ( 'angular-cli.json' , configJson => {
22
+ const app = configJson [ 'apps' ] [ 0 ] ;
23
+ app [ 'index' ] = 'not-index.html' ;
24
+ } ) )
25
+ . then ( ( ) => ngServe ( ) )
26
+ . then ( ( ) => request ( 'http://localhost:4200/' ) )
27
+ . then ( body => {
28
+ console . log ( body )
29
+ if ( ! body . match ( / < a p p - r o o t > L o a d i n g ...< \/ a p p - r o o t > / ) ) {
30
+ throw new Error ( 'Response does not match expected value.' ) ;
31
+ }
32
+ } )
33
+ . then ( ( ) => killAllProcesses ( ) , ( err ) => { killAllProcesses ( ) ; throw err ; } ) ;
34
+ }
You can’t perform that action at this time.
0 commit comments