Navigation Menu

Skip to content

Commit

Permalink
grunt dev admin livereload (#8176)
Browse files Browse the repository at this point in the history
refs #8161, requires TryGhost/Admin#590
- adds a development-only route to the admin app that redirects to ember-cli's livereload script
- updates Gruntfile `watch` task to pass the `live-reload-base-url` param with subdirectory support
- updates Gruntfile `bgShell:client` task to filter potentially confusing output from `ember serve`
  - removes `Livereload server on http://localhost:49153`
  - removes `Serving on http://localhost:4200/`

With this and the required Ghost-Admin PR, when using `grunt dev` the admin screen will refresh any time a file is changed. It will also allow client tests to be run simultaneously by visiting http://localhost:4200/tests
  • Loading branch information
kevinansfield authored and ErisDS committed Mar 30, 2017
1 parent b8e4613 commit c9e0c25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Gruntfile.js
Expand Up @@ -9,6 +9,7 @@
// jshint unused: false
var overrides = require('./core/server/overrides'),
config = require('./core/server/config'),
utils = require('./core/server/utils'),
_ = require('lodash'),
chalk = require('chalk'),
fs = require('fs-extra'),
Expand Down Expand Up @@ -219,7 +220,20 @@ var overrides = require('./core/server/overrides'),
client: {
cmd: 'grunt subgrunt:watch',
bg: true,
stdout: true,
stdout: function (chunk) {
// hide certain output to prevent confusion
var filter = [
/> ghost-admin/,
/^Livereload/,
/^Serving on/
].some(function (regexp) {
return regexp.test(chunk);
});

if (!filter) {
grunt.log.write(chunk);
}
},
stderr: true
}
},
Expand Down Expand Up @@ -339,7 +353,9 @@ var overrides = require('./core/server/overrides'),
},

watch: {
'core/client': 'shell:ember:watch'
projects: {
'core/client': ['shell:ember:watch', '--live-reload-base-url="' + utils.url.getSubdir() + '/ghost/"']
}
}
}
};
Expand Down
7 changes: 7 additions & 0 deletions core/server/admin/app.js
Expand Up @@ -36,6 +36,13 @@ module.exports = function setupAdminApp() {
// Service Worker for offline support
adminApp.get(/^\/(sw.js|sw-registration.js)$/, require('./serviceworker'));

// Ember CLI's live-reload script
if (config.get('env') === 'development') {
adminApp.get('/ember-cli-live-reload.js', function (req, res) {
res.redirect('http://localhost:4200' + utils.url.getSubdir() + '/ghost/ember-cli-live-reload.js');
});
}

// Render error page in case of maintenance
adminApp.use(maintenance);

Expand Down

0 comments on commit c9e0c25

Please sign in to comment.