mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
b1d6b434b5
refs https://github.com/TryGhost/Toolbox/issues/365 - this fixes the path of the admin assets to the ghost package dir and points the subgrunt path to the admin dir
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
/* eslint-disable */
|
|
'use strict';
|
|
|
|
module.exports = {
|
|
name: 'asset-delivery',
|
|
|
|
env: null,
|
|
|
|
isDevelopingAddon() {
|
|
return true;
|
|
},
|
|
|
|
config(env) {
|
|
// only set this.env on the first call otherwise when `postBuild()` is
|
|
// called this.env will always be 'test' due to multiple `config()` calls
|
|
if (!this.env) {
|
|
this.env = env;
|
|
}
|
|
},
|
|
|
|
postBuild: function (results) {
|
|
const fs = this.project.require('fs-extra');
|
|
const walkSync = this.project.require('walk-sync');
|
|
|
|
const assetsOut = `../core/core/built/admin/${this.env}`;
|
|
fs.ensureDirSync(assetsOut);
|
|
|
|
// the dist folder contains more than just index.html and /assets, especially
|
|
// for development builds but for Ghost's purposes it only needs to serve
|
|
// index.html and /assets
|
|
|
|
// copy the index.html file
|
|
fs.copySync(`${results.directory}/index.html`, `${assetsOut}/index.html`, {overwrite: true, dereference: true});
|
|
|
|
// copy all the `/assets` files
|
|
const assets = walkSync(results.directory + '/assets');
|
|
|
|
assets.forEach(function (relativePath) {
|
|
if (relativePath.slice(-1) === '/') { return; }
|
|
|
|
fs.copySync(`${results.directory}/assets/${relativePath}`, `${assetsOut}/assets/${relativePath}`, {overwrite: true, dereference: true});
|
|
});
|
|
}
|
|
};
|