mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated admin asset serving for ember-auto-import@2 compatibility (#15128)
refs https://github.com/TryGhost/Admin/pull/2252 closes https://github.com/TryGhost/Team/issues/1182 - Admin now copies it's build output to a single env-specific directory rather than splitting html and assets - `core/built/admin/{development|production}/*` - updated the admin app's `serveStatic` definition for assets and controller's html serving to reflect the new asset paths
This commit is contained in:
parent
bcafb84c44
commit
0a34be4012
11 changed files with 17 additions and 18 deletions
1
ghost/core/.gitignore
vendored
1
ghost/core/.gitignore
vendored
|
@ -126,7 +126,6 @@ test/coverage
|
|||
# Built asset files
|
||||
/core/built
|
||||
/core/frontend/public/ghost.min.css
|
||||
/core/server/web/admin/views/*.html
|
||||
|
||||
# Caddyfile - for local development with ssl + caddy
|
||||
Caddyfile
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const debug = require('@tryghost/debug')('web:admin:app');
|
||||
const path = require('path');
|
||||
const express = require('../../../shared/express');
|
||||
const serveStatic = express.static;
|
||||
const config = require('../../../shared/config');
|
||||
|
@ -16,8 +17,9 @@ module.exports = function setupAdminApp() {
|
|||
// Admin assets
|
||||
// @TODO ensure this gets a local 404 error handler
|
||||
const configMaxAge = config.get('caching:admin:maxAge');
|
||||
const envDir = config.get('env') === 'production' ? 'production' : 'development';
|
||||
adminApp.use('/assets', serveStatic(
|
||||
config.get('paths').adminAssets,
|
||||
path.join(config.get('paths').adminAssets, envDir, 'assets'),
|
||||
{maxAge: (configMaxAge || configMaxAge === 0) ? configMaxAge : constants.ONE_YEAR_MS, fallthrough: false}
|
||||
));
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ module.exports = function adminController(req, res) {
|
|||
// CASE: trigger update check unit and let it run in background, don't block the admin rendering
|
||||
updateCheck();
|
||||
|
||||
const defaultTemplate = config.get('env') === 'production' ? 'default-prod.html' : 'default.html';
|
||||
const templatePath = path.resolve(config.get('paths').adminViews, defaultTemplate);
|
||||
const envDir = config.get('env') === 'production' ? 'production' : 'development';
|
||||
const templatePath = path.resolve(config.get('paths').adminAssets, envDir, 'index.html');
|
||||
const headers = {};
|
||||
|
||||
try {
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
"paths": {
|
||||
"appRoot": ".",
|
||||
"corePath": "core/",
|
||||
"adminAssets": "core/built/assets",
|
||||
"adminAssets": "core/built/admin",
|
||||
"adminAuthAssets": "content/public/admin-auth",
|
||||
"helperTemplates": "core/frontend/helpers/tpl/",
|
||||
"adminViews": "core/server/web/admin/views/",
|
||||
"defaultViews": "core/server/views/",
|
||||
"defaultRouteSettings": "core/server/services/route-settings/",
|
||||
"internalAppPath": "core/frontend/apps/",
|
||||
|
|
|
@ -86,7 +86,7 @@ describe('Admin Routing', function () {
|
|||
describe('built template', function () {
|
||||
beforeEach(function () {
|
||||
const configPaths = configUtils.config.get('paths');
|
||||
configPaths.adminViews = path.resolve('test/utils/fixtures/admin-views');
|
||||
configPaths.adminAssets = path.resolve('test/utils/fixtures/admin-build');
|
||||
configUtils.set('paths', configPaths);
|
||||
});
|
||||
|
||||
|
@ -94,10 +94,10 @@ describe('Admin Routing', function () {
|
|||
configUtils.restore();
|
||||
});
|
||||
|
||||
it('serves prod file in production', async function () {
|
||||
it('serves prod assets in production', async function () {
|
||||
configUtils.set('env', 'production');
|
||||
|
||||
const prodTemplate = fs.readFileSync(path.resolve('test/utils/fixtures/admin-views/default-prod.html')).toString();
|
||||
const prodTemplate = fs.readFileSync(path.resolve('test/utils/fixtures/admin-build/production/index.html')).toString();
|
||||
|
||||
const res = await request.get('/ghost/')
|
||||
.set('X-Forwarded-Proto', 'https')
|
||||
|
@ -106,8 +106,8 @@ describe('Admin Routing', function () {
|
|||
res.text.should.equal(prodTemplate);
|
||||
});
|
||||
|
||||
it('serves dev file when not in production', async function () {
|
||||
const devTemplate = fs.readFileSync(path.resolve('test/utils/fixtures/admin-views/default.html')).toString();
|
||||
it('serves dev assets when not in production', async function () {
|
||||
const devTemplate = fs.readFileSync(path.resolve('test/utils/fixtures/admin-build/development/index.html')).toString();
|
||||
|
||||
const res = await request.get('/ghost/')
|
||||
.set('X-Forwarded-Proto', 'https')
|
||||
|
|
|
@ -15,7 +15,7 @@ describe('Admin App', function () {
|
|||
};
|
||||
|
||||
configUtils.restore();
|
||||
configUtils.set('paths:adminViews', path.resolve('test/utils/fixtures/admin-views'));
|
||||
configUtils.set('paths:adminAssets', path.resolve('test/utils/fixtures/admin-build'));
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
|
|
|
@ -104,7 +104,6 @@ describe('Config Loader', function () {
|
|||
'adminAssets',
|
||||
'adminAuthAssets',
|
||||
'helperTemplates',
|
||||
'adminViews',
|
||||
'defaultViews',
|
||||
'defaultRouteSettings',
|
||||
'internalAppPath',
|
||||
|
|
|
@ -2,11 +2,11 @@ const fs = require('fs-extra');
|
|||
const path = require('path');
|
||||
|
||||
const adminFiles = [
|
||||
'server/web/admin/views/default.html',
|
||||
'built/assets/ghost.js',
|
||||
'built/assets/ghost.css',
|
||||
'built/assets/vendor.js',
|
||||
'built/assets/vendor.css'
|
||||
'built/admin/development/index.html',
|
||||
'built/admin/development/assets/ghost.js',
|
||||
'built/admin/development/assets/ghost.css',
|
||||
'built/admin/development/assets/vendor.js',
|
||||
'built/admin/development/assets/vendor.css'
|
||||
];
|
||||
|
||||
module.exports.stubAdminFiles = () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue