2017-03-28 13:29:18 +03:00
|
|
|
/* eslint-env node */
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const EmberApp = require('ember-cli/lib/broccoli/ember-app');
|
|
|
|
const concat = require('broccoli-concat');
|
|
|
|
const mergeTrees = require('broccoli-merge-trees');
|
2020-09-09 19:22:23 +03:00
|
|
|
const Terser = require('broccoli-terser-sourcemap');
|
2019-01-21 19:06:25 +03:00
|
|
|
const Funnel = require('broccoli-funnel');
|
2017-03-28 13:29:18 +03:00
|
|
|
const environment = EmberApp.env();
|
|
|
|
const isProduction = environment === 'production';
|
2015-09-03 13:03:45 +03:00
|
|
|
|
2021-01-19 12:25:05 +03:00
|
|
|
const postcssImport = require('postcss-import');
|
2019-02-24 07:19:06 +03:00
|
|
|
const postcssCustomProperties = require('postcss-custom-properties');
|
|
|
|
const postcssColorModFunction = require('postcss-color-mod-function');
|
|
|
|
const postcssCustomMedia = require('postcss-custom-media');
|
|
|
|
const autoprefixer = require('autoprefixer');
|
|
|
|
const cssnano = require('cssnano');
|
|
|
|
|
2019-01-21 19:06:25 +03:00
|
|
|
const assetLocation = function (fileName) {
|
2015-09-03 13:03:45 +03:00
|
|
|
if (isProduction) {
|
|
|
|
fileName = fileName.replace('.', '.min.');
|
|
|
|
}
|
2017-03-28 13:29:18 +03:00
|
|
|
return `/assets/${fileName}`;
|
2015-09-03 13:03:45 +03:00
|
|
|
};
|
|
|
|
|
2019-01-21 19:06:25 +03:00
|
|
|
const codemirrorAssets = function () {
|
2017-03-28 13:29:18 +03:00
|
|
|
let codemirrorFiles = [
|
2016-07-05 19:30:14 +03:00
|
|
|
'lib/codemirror.js',
|
|
|
|
'mode/htmlmixed/htmlmixed.js',
|
|
|
|
'mode/xml/xml.js',
|
|
|
|
'mode/css/css.js',
|
|
|
|
'mode/javascript/javascript.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
if (environment === 'test') {
|
|
|
|
return {import: codemirrorFiles};
|
|
|
|
}
|
|
|
|
|
2017-03-30 22:51:50 +03:00
|
|
|
let config = {};
|
|
|
|
|
|
|
|
config.public = {
|
|
|
|
include: codemirrorFiles,
|
|
|
|
destDir: '/',
|
|
|
|
processTree(tree) {
|
|
|
|
let jsTree = concat(tree, {
|
|
|
|
outputFile: 'assets/codemirror/codemirror.js',
|
|
|
|
headerFiles: ['lib/codemirror.js'],
|
|
|
|
inputFiles: ['mode/**/*'],
|
|
|
|
sourceMapConfig: {enabled: false}
|
|
|
|
});
|
|
|
|
|
2019-01-21 19:06:25 +03:00
|
|
|
if (isProduction) {
|
2020-09-09 19:22:23 +03:00
|
|
|
jsTree = new Terser(jsTree);
|
2019-01-21 19:06:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
let mergedTree = mergeTrees([tree, jsTree]);
|
|
|
|
return new Funnel(mergedTree, {include: ['assets/**/*', 'theme/**/*']});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// put the files in vendor ready for importing into the test-support file
|
|
|
|
if (environment === 'development') {
|
|
|
|
config.vendor = codemirrorFiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
|
|
|
};
|
|
|
|
|
|
|
|
const simplemdeAssets = function () {
|
|
|
|
let simplemdeFiles = [
|
|
|
|
'debug/simplemde.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
if (environment === 'test') {
|
|
|
|
return {import: simplemdeFiles};
|
|
|
|
}
|
|
|
|
|
|
|
|
let config = {};
|
|
|
|
|
|
|
|
config.public = {
|
|
|
|
include: simplemdeFiles,
|
|
|
|
destDir: '/',
|
|
|
|
processTree(tree) {
|
|
|
|
let jsTree = concat(tree, {
|
|
|
|
outputFile: 'assets/simplemde/simplemde.js',
|
|
|
|
inputFiles: ['debug/simplemde.js'],
|
|
|
|
sourceMapConfig: {enabled: false}
|
2017-03-30 22:51:50 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
if (isProduction) {
|
2020-09-09 19:22:23 +03:00
|
|
|
jsTree = new Terser(jsTree);
|
2016-07-05 19:30:14 +03:00
|
|
|
}
|
2017-03-30 22:51:50 +03:00
|
|
|
|
2019-01-21 19:06:25 +03:00
|
|
|
let mergedTree = mergeTrees([tree, jsTree]);
|
|
|
|
return new Funnel(mergedTree, {include: ['assets/**/*']});
|
2016-07-05 19:30:14 +03:00
|
|
|
}
|
|
|
|
};
|
2017-03-30 22:51:50 +03:00
|
|
|
|
|
|
|
// put the files in vendor ready for importing into the test-support file
|
|
|
|
if (environment === 'development') {
|
2019-01-21 19:06:25 +03:00
|
|
|
config.vendor = simplemdeFiles;
|
2017-03-30 22:51:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return config;
|
2016-07-05 19:30:14 +03:00
|
|
|
};
|
|
|
|
|
2022-05-09 14:23:20 +03:00
|
|
|
let denylist = [];
|
2019-03-11 18:45:26 +03:00
|
|
|
if (process.env.CI) {
|
2022-05-09 14:23:20 +03:00
|
|
|
denylist.push('ember-cli-eslint');
|
2019-03-11 18:45:26 +03:00
|
|
|
}
|
|
|
|
|
2015-09-03 13:03:45 +03:00
|
|
|
module.exports = function (defaults) {
|
2017-03-28 13:29:18 +03:00
|
|
|
let app = new EmberApp(defaults, {
|
2022-05-09 14:23:20 +03:00
|
|
|
addons: {denylist},
|
2017-02-17 22:46:41 +03:00
|
|
|
'ember-cli-babel': {
|
2016-02-04 15:49:53 +03:00
|
|
|
optional: ['es6.spec.symbols'],
|
2019-01-22 17:03:27 +03:00
|
|
|
includePolyfill: false
|
2016-02-04 15:49:53 +03:00
|
|
|
},
|
2017-02-21 15:28:05 +03:00
|
|
|
'ember-composable-helpers': {
|
2022-04-19 23:56:13 +03:00
|
|
|
only: ['join', 'optional', 'pick', 'toggle', 'toggle-action']
|
2017-02-21 15:28:05 +03:00
|
|
|
},
|
2021-09-03 20:14:28 +03:00
|
|
|
'ember-promise-modals': {
|
|
|
|
excludeCSS: true
|
|
|
|
},
|
2015-09-03 13:03:45 +03:00
|
|
|
outputPaths: {
|
|
|
|
app: {
|
2017-03-14 19:04:46 +03:00
|
|
|
html: isProduction ? 'index.min.html' : 'index.html',
|
2017-02-17 22:46:41 +03:00
|
|
|
js: assetLocation('ghost.js'),
|
|
|
|
css: {
|
|
|
|
app: assetLocation('ghost.css'),
|
2017-04-05 12:39:07 +03:00
|
|
|
// TODO: find a way to use the .min file with the lazyLoader
|
|
|
|
'app-dark': 'assets/ghost-dark.css'
|
2017-02-17 22:46:41 +03:00
|
|
|
}
|
2015-09-03 13:03:45 +03:00
|
|
|
},
|
|
|
|
vendor: {
|
2018-01-05 18:38:23 +03:00
|
|
|
js: assetLocation('vendor.js'),
|
2015-09-03 13:03:45 +03:00
|
|
|
css: assetLocation('vendor.css')
|
|
|
|
}
|
|
|
|
},
|
2017-04-05 16:08:15 +03:00
|
|
|
fingerprint: {
|
2018-05-21 11:37:17 +03:00
|
|
|
enabled: isProduction,
|
2017-04-05 16:08:15 +03:00
|
|
|
extensions: ['js', 'css', 'png', 'jpg', 'jpeg', 'gif', 'map']
|
|
|
|
},
|
2017-09-18 18:39:03 +03:00
|
|
|
minifyJS: {
|
|
|
|
options: {
|
|
|
|
output: {
|
|
|
|
semicolons: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-05-20 13:05:11 +03:00
|
|
|
minifyCSS: {
|
|
|
|
// postcss already handles minification and this was stripping required CSS
|
|
|
|
enabled: false
|
|
|
|
},
|
2016-06-29 11:25:51 +03:00
|
|
|
nodeAssets: {
|
2019-01-21 19:06:25 +03:00
|
|
|
codemirror: codemirrorAssets(),
|
|
|
|
simplemde: simplemdeAssets()
|
2016-06-29 11:25:51 +03:00
|
|
|
},
|
2019-02-24 07:19:06 +03:00
|
|
|
postcssOptions: {
|
|
|
|
compile: {
|
|
|
|
enabled: true,
|
|
|
|
plugins: [
|
|
|
|
{
|
2021-01-19 12:25:05 +03:00
|
|
|
module: postcssImport,
|
2019-02-24 07:19:06 +03:00
|
|
|
options: {
|
|
|
|
path: ['app/styles']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
module: postcssCustomProperties,
|
|
|
|
options: {
|
|
|
|
preserve: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
module: postcssColorModFunction
|
|
|
|
},
|
|
|
|
{
|
|
|
|
module: postcssCustomMedia
|
|
|
|
},
|
|
|
|
{
|
|
|
|
module: autoprefixer
|
|
|
|
},
|
|
|
|
{
|
|
|
|
module: cssnano,
|
|
|
|
options: {
|
|
|
|
zindex: false,
|
|
|
|
// cssnano sometimes minifies animations incorrectly causing them to break
|
|
|
|
// See: https://github.com/ben-eb/gulp-cssnano/issues/33#issuecomment-210518957
|
|
|
|
reduceIdents: {
|
|
|
|
keyframes: false
|
|
|
|
},
|
|
|
|
discardUnused: {
|
|
|
|
keyframes: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2021-05-27 20:54:25 +03:00
|
|
|
sourcemaps: {enabled: true},
|
2018-03-19 12:57:31 +03:00
|
|
|
svgJar: {
|
2018-03-19 16:10:04 +03:00
|
|
|
strategy: 'inline',
|
|
|
|
stripPath: false,
|
|
|
|
sourceDirs: [
|
2018-01-31 18:20:27 +03:00
|
|
|
'public/assets/icons',
|
|
|
|
'lib/koenig-editor/public/icons'
|
2017-03-01 15:48:27 +03:00
|
|
|
],
|
2018-03-19 12:57:31 +03:00
|
|
|
optimizer: {
|
2017-03-01 15:48:27 +03:00
|
|
|
plugins: [
|
2019-08-28 13:33:32 +03:00
|
|
|
{prefixIds: true},
|
|
|
|
{cleanupIds: false},
|
2017-03-01 15:48:27 +03:00
|
|
|
{removeDimensions: true},
|
|
|
|
{removeTitle: true},
|
2017-04-14 18:16:52 +03:00
|
|
|
{removeXMLNS: true},
|
|
|
|
// Transforms on groups are necessary to work around Firefox
|
|
|
|
// not supporting transform-origin on line/path elements.
|
|
|
|
{convertPathData: {
|
|
|
|
applyTransforms: false
|
|
|
|
}},
|
|
|
|
{moveGroupAttrsToElems: false}
|
2017-03-01 15:48:27 +03:00
|
|
|
]
|
|
|
|
}
|
2021-09-09 12:35:15 +03:00
|
|
|
},
|
|
|
|
autoImport: {
|
|
|
|
webpack: {
|
|
|
|
node: {
|
|
|
|
util: true,
|
|
|
|
fs: 'empty',
|
|
|
|
path: true
|
|
|
|
}
|
|
|
|
}
|
2015-09-03 13:03:45 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-03-19 20:56:09 +03:00
|
|
|
// Stop: Normalize
|
|
|
|
app.import('node_modules/normalize.css/normalize.css');
|
2019-01-21 19:06:25 +03:00
|
|
|
|
|
|
|
// 'dem Styles
|
|
|
|
// import codemirror + simplemde styles rather than lazy-loading so that
|
|
|
|
// our overrides work correctly
|
2019-04-29 18:57:41 +03:00
|
|
|
app.import('node_modules/codemirror/lib/codemirror.css');
|
|
|
|
app.import('node_modules/codemirror/theme/xq-light.css');
|
2019-01-21 19:06:25 +03:00
|
|
|
app.import('node_modules/simplemde/dist/simplemde.min.css');
|
2018-03-19 20:56:09 +03:00
|
|
|
|
2015-09-03 13:03:45 +03:00
|
|
|
// 'dem Scripts
|
2018-03-19 20:56:09 +03:00
|
|
|
app.import('node_modules/google-caja-bower/html-css-sanitizer-bundle.js');
|
|
|
|
app.import('node_modules/keymaster/keymaster.js');
|
2018-07-17 19:45:31 +03:00
|
|
|
app.import('node_modules/@tryghost/mobiledoc-kit/dist/amd/mobiledoc-kit.js');
|
|
|
|
app.import('node_modules/@tryghost/mobiledoc-kit/dist/amd/mobiledoc-kit.map');
|
2019-03-05 20:34:00 +03:00
|
|
|
app.import('node_modules/reframe.js/dist/noframe.js');
|
2015-09-16 20:02:06 +03:00
|
|
|
|
2017-03-30 22:51:50 +03:00
|
|
|
// pull things we rely on via lazy-loading into the test-support.js file so
|
|
|
|
// that tests don't break when running via http://localhost:4200/tests
|
|
|
|
if (app.env === 'development') {
|
|
|
|
app.import('vendor/codemirror/lib/codemirror.js', {type: 'test'});
|
2019-01-21 19:06:25 +03:00
|
|
|
app.import('vendor/simplemde/debug/simplemde.js', {type: 'test'});
|
2017-03-30 22:51:50 +03:00
|
|
|
}
|
|
|
|
|
2015-09-03 13:03:45 +03:00
|
|
|
return app.toTree();
|
|
|
|
};
|