2016-11-16 15:27:30 +03:00
|
|
|
/* eslint-disable */
|
2017-03-14 19:04:46 +03:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-03 09:25:56 +03:00
|
|
|
module.exports = {
|
|
|
|
name: 'asset-delivery',
|
2017-03-14 19:04:46 +03:00
|
|
|
|
|
|
|
isDevelopingAddon() {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
contentFor(type, config) {
|
|
|
|
let min = config.environment === 'production' ? '.min' : '';
|
|
|
|
|
|
|
|
if (type === 'minifiedInProductionCss') {
|
|
|
|
return `
|
|
|
|
<link rel="stylesheet" href="assets/vendor${min}.css">
|
|
|
|
<link rel="stylesheet" href="assets/ghost${min}.css" title="light">
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type === 'minifiedInProductionJs') {
|
|
|
|
return `
|
|
|
|
<script src="assets/vendor${min}.js"></script>
|
|
|
|
<script src="assets/ghost${min}.js"></script>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-06-03 09:25:56 +03:00
|
|
|
postBuild: function (results) {
|
|
|
|
var fs = this.project.require('fs-extra'),
|
2015-08-21 19:17:39 +03:00
|
|
|
walkSync = this.project.require('walk-sync'),
|
|
|
|
assetsIn = results.directory + '/assets',
|
2017-12-06 19:37:06 +03:00
|
|
|
templateOutDir = '../server/web/admin/views',
|
2015-08-21 19:17:39 +03:00
|
|
|
assetsOut = '../built/assets',
|
|
|
|
assets = walkSync(assetsIn);
|
2015-02-14 07:03:16 +03:00
|
|
|
|
2015-06-03 09:25:56 +03:00
|
|
|
fs.ensureDirSync(assetsOut);
|
|
|
|
|
2017-03-14 19:04:46 +03:00
|
|
|
if (fs.existsSync(results.directory + '/index.min.html')) {
|
2017-03-20 15:01:06 +03:00
|
|
|
fs.copySync(results.directory + '/index.min.html', `${templateOutDir}/default-prod.html`, {overwrite: true});
|
2017-03-14 19:04:46 +03:00
|
|
|
} else {
|
2017-03-20 15:01:06 +03:00
|
|
|
fs.copySync(results.directory + '/index.html', `${templateOutDir}/default.html`, {overwrite: true});
|
2017-03-14 19:04:46 +03:00
|
|
|
}
|
2015-08-21 19:17:39 +03:00
|
|
|
|
|
|
|
assets.forEach(function (relativePath) {
|
|
|
|
if (relativePath.slice(-1) === '/') { return; }
|
|
|
|
|
2017-01-16 22:45:13 +03:00
|
|
|
fs.copySync(assetsIn + '/' + relativePath, assetsOut + '/' + relativePath, {overwrite: true});
|
2015-08-21 19:17:39 +03:00
|
|
|
});
|
2015-06-03 09:25:56 +03:00
|
|
|
}
|
|
|
|
};
|