mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03:00
Added minified members.js file handling
refs 91984b54ca
- For request effieciency we should be using a minified file just like we did previously with `ghost-sdk.js`
- Modified 'max-age' caching header to 1 year for both minified and non-minified files as thay won't affect dev environment and should be beneficial for self-hosting instances that don't use minification
- Along the way corrected an extra 301 redirect because `/public/member.js` path wasn't using a bakslach in the end.
This commit is contained in:
parent
3af621ea9a
commit
258bcc71bf
13
Gruntfile.js
13
Gruntfile.js
@ -264,6 +264,17 @@ const configureGrunt = function (grunt) {
|
||||
}
|
||||
},
|
||||
|
||||
uglify: {
|
||||
prod: {
|
||||
options: {
|
||||
sourceMap: false
|
||||
},
|
||||
files: {
|
||||
'core/server/public/members.min.js': 'core/server/public/members.js'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
cssnano: {
|
||||
prod: {
|
||||
options: {
|
||||
@ -530,7 +541,7 @@ const configureGrunt = function (grunt) {
|
||||
//
|
||||
// It is otherwise the same as running `grunt`, but is only used when running Ghost in the `production` env.
|
||||
grunt.registerTask('prod', 'Build JS & templates for production',
|
||||
['subgrunt:prod', 'cssnano:prod', 'master-warn']);
|
||||
['subgrunt:prod', 'uglify:prod', 'cssnano:prod', 'master-warn']);
|
||||
|
||||
// ### Live reload
|
||||
// `grunt dev` - build assets on the fly whilst developing
|
||||
|
@ -50,7 +50,7 @@ function getMembersHelper() {
|
||||
const stripeSecretToken = stripePaymentProcessor.config.secret_token;
|
||||
const stripePublicToken = stripePaymentProcessor.config.public_token;
|
||||
|
||||
let membersHelper = `<script defer src="${getAssetUrl('public/members.js')}"></script>`;
|
||||
let membersHelper = `<script defer src="${getAssetUrl('public/members.js/', true)}"></script>`;
|
||||
if (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== '') {
|
||||
membersHelper += '<script src="https://js.stripe.com/v3/"></script>';
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ Array.prototype.forEach.call(document.querySelectorAll('[data-members-cancel-sub
|
||||
|
||||
return res.text();
|
||||
}).then(function (identity) {
|
||||
return fetch(`{{admin-url}}/api/canary/members/subscriptions/${subscriptionId}/`, {
|
||||
return fetch('{{admin-url}}/api/canary/members/subscriptions/' + subscriptionId + '/', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@ -282,7 +282,7 @@ Array.prototype.forEach.call(document.querySelectorAll('[data-members-continue-s
|
||||
|
||||
return res.text();
|
||||
}).then(function (identity) {
|
||||
return fetch(`{{admin-url}}/api/canary/members/subscriptions/${subscriptionId}/`, {
|
||||
return fetch('{{admin-url}}/api/canary/members/subscriptions/' + subscriptionId + '/', {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
2
core/server/public/members.min.js
vendored
2
core/server/public/members.min.js
vendored
File diff suppressed because one or more lines are too long
@ -74,7 +74,15 @@ module.exports = {
|
||||
shared.middlewares.servePublicFile.createPublicFileMiddleware(
|
||||
'public/members.js',
|
||||
'application/javascript',
|
||||
constants.ONE_HOUR_S
|
||||
constants.ONE_YEAR_S
|
||||
)
|
||||
],
|
||||
publicMinified: [
|
||||
shared.middlewares.labs.members,
|
||||
shared.middlewares.servePublicFile.createPublicFileMiddleware(
|
||||
'public/members.min.js',
|
||||
'application/javascript',
|
||||
constants.ONE_YEAR_S
|
||||
)
|
||||
],
|
||||
createSessionFromToken: [
|
||||
|
@ -109,6 +109,8 @@ module.exports = function setupSiteApp(options = {}) {
|
||||
|
||||
// /public/members.js
|
||||
siteApp.get('/public/members.js', membersMiddleware.public);
|
||||
// /public/members.min.js
|
||||
siteApp.get('/public/members.min.js', membersMiddleware.publicMinified);
|
||||
|
||||
// Serve sitemap.xsl file
|
||||
siteApp.use(shared.middlewares.servePublicFile('sitemap.xsl', 'text/xsl', constants.ONE_DAY_S));
|
||||
|
Loading…
Reference in New Issue
Block a user