@@ -10,7 +10,7 @@ require('dotenv').config({silent: true});
10
10
var chalk = require ( 'chalk' ) ;
11
11
var fs = require ( 'fs-extra' ) ;
12
12
var path = require ( 'path' ) ;
13
- var pathExists = require ( 'path-exists ' ) ;
13
+ var url = require ( 'url ' ) ;
14
14
var filesize = require ( 'filesize' ) ;
15
15
var gzipSize = require ( 'gzip-size' ) . sync ;
16
16
var webpack = require ( 'webpack' ) ;
@@ -20,7 +20,7 @@ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
20
20
var recursive = require ( 'recursive-readdir' ) ;
21
21
var stripAnsi = require ( 'strip-ansi' ) ;
22
22
23
- var useYarn = pathExists . sync ( paths . yarnLockFile ) ;
23
+ var useYarn = fs . existsSync ( paths . yarnLockFile ) ;
24
24
25
25
// Warn and crash if required files are missing
26
26
if ( ! checkRequiredFiles ( [ paths . appHtml , paths . appIndexJs ] ) ) {
@@ -134,7 +134,7 @@ function build(previousSizeMap) {
134
134
}
135
135
136
136
if ( process . env . CI && stats . compilation . warnings . length ) {
137
- printErrors ( 'Failed to compile.' , stats . compilation . warnings ) ;
137
+ printErrors ( 'Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically. ' , stats . compilation . warnings ) ;
138
138
process . exit ( 1 ) ;
139
139
}
140
140
@@ -148,15 +148,16 @@ function build(previousSizeMap) {
148
148
149
149
var openCommand = process . platform === 'win32' ? 'start' : 'open' ;
150
150
var appPackage = require ( paths . appPackageJson ) ;
151
- var homepagePath = appPackage . homepage ;
151
+ var publicUrl = paths . publicUrl ;
152
152
var publicPath = config . output . publicPath ;
153
- if ( homepagePath && homepagePath . indexOf ( '.github.io/' ) !== - 1 ) {
153
+ var publicPathname = url . parse ( publicPath ) . pathname ;
154
+ if ( publicUrl && publicUrl . indexOf ( '.github.io/' ) !== - 1 ) {
154
155
// "homepage": "http://user.github.io/project"
155
- console . log ( 'The project was built assuming it is hosted at ' + chalk . green ( publicPath ) + '.' ) ;
156
+ console . log ( 'The project was built assuming it is hosted at ' + chalk . green ( publicPathname ) + '.' ) ;
156
157
console . log ( 'You can control this with the ' + chalk . green ( 'homepage' ) + ' field in your ' + chalk . cyan ( 'package.json' ) + '.' ) ;
157
158
console . log ( ) ;
158
159
console . log ( 'The ' + chalk . cyan ( 'build' ) + ' folder is ready to be deployed.' ) ;
159
- console . log ( 'To publish it at ' + chalk . green ( homepagePath ) + ', run:' ) ;
160
+ console . log ( 'To publish it at ' + chalk . green ( publicUrl ) + ', run:' ) ;
160
161
// If script deploy has been added to package.json, skip the instructions
161
162
if ( typeof appPackage . scripts . deploy === 'undefined' ) {
162
163
console . log ( ) ;
@@ -171,7 +172,8 @@ function build(previousSizeMap) {
171
172
console . log ( ' ' + chalk . dim ( '// ...' ) ) ;
172
173
console . log ( ' ' + chalk . yellow ( '"scripts"' ) + ': {' ) ;
173
174
console . log ( ' ' + chalk . dim ( '// ...' ) ) ;
174
- console . log ( ' ' + chalk . yellow ( '"deploy"' ) + ': ' + chalk . yellow ( '"npm run build&&gh-pages -d build"' ) ) ;
175
+ console . log ( ' ' + chalk . yellow ( '"predeploy"' ) + ': ' + chalk . yellow ( '"npm run build",' ) ) ;
176
+ console . log ( ' ' + chalk . yellow ( '"deploy"' ) + ': ' + chalk . yellow ( '"gh-pages -d build"' ) ) ;
175
177
console . log ( ' }' ) ;
176
178
console . log ( ) ;
177
179
console . log ( 'Then run:' ) ;
@@ -187,14 +189,14 @@ function build(previousSizeMap) {
187
189
console . log ( 'The ' + chalk . cyan ( 'build' ) + ' folder is ready to be deployed.' ) ;
188
190
console . log ( ) ;
189
191
} else {
190
- // no homepage or "homepage": "http://mywebsite.com"
191
- console . log ( 'The project was built assuming it is hosted at the server root.' ) ;
192
- if ( homepagePath ) {
192
+ if ( publicUrl ) {
193
193
// "homepage": "http://mywebsite.com"
194
+ console . log ( 'The project was built assuming it is hosted at ' + chalk . green ( publicUrl ) + '.' ) ;
194
195
console . log ( 'You can control this with the ' + chalk . green ( 'homepage' ) + ' field in your ' + chalk . cyan ( 'package.json' ) + '.' ) ;
195
196
console . log ( ) ;
196
197
} else {
197
198
// no homepage
199
+ console . log ( 'The project was built assuming it is hosted at the server root.' ) ;
198
200
console . log ( 'To override this, specify the ' + chalk . green ( 'homepage' ) + ' in your ' + chalk . cyan ( 'package.json' ) + '.' ) ;
199
201
console . log ( 'For example, add this to build it for GitHub Pages:' )
200
202
console . log ( ) ;
0 commit comments