File tree 3 files changed +43
-7
lines changed
packages/angular-cli/tasks
3 files changed +43
-7
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 . join ( 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,8 +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 &&
102
- CliConfig . fromProject ( ) . config . defaults . poll
101
+ poll : projectConfig . defaults && projectConfig . defaults . poll
103
102
} ,
104
103
https : serveTaskOptions . ssl
105
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
+ if ( ! body . match ( / < a p p - r o o t > L o a d i n g ...< \/ a p p - r o o t > / ) ) {
29
+ throw new Error ( 'Response does not match expected value.' ) ;
30
+ }
31
+ } )
32
+ . then ( ( ) => killAllProcesses ( ) , ( err ) => { killAllProcesses ( ) ; throw err ; } ) ;
33
+ }
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ import * as _request from 'request';
4
4
5
5
export function request ( url : string ) : Promise < string > {
6
6
return new Promise ( ( resolve , reject ) => {
7
- let options = { url : url , agentOptions : { rejectUnauthorized : false } } ;
7
+ let options = {
8
+ url : url ,
9
+ headers : { 'Accept' : 'text/html' } ,
10
+ agentOptions : { rejectUnauthorized : false }
11
+ } ;
8
12
_request ( options , ( error : any , response : IncomingMessage , body : string ) => {
9
13
if ( error ) {
10
14
reject ( error ) ;
You can’t perform that action at this time.
0 commit comments