Skip to content

Instantly share code, notes, and snippets.

@ianpetzer
Created June 21, 2018 13:36
Show Gist options
  • Save ianpetzer/f7187cefa341a8b4b47057195b4a7bb7 to your computer and use it in GitHub Desktop.
Save ianpetzer/f7187cefa341a8b4b47057195b4a7bb7 to your computer and use it in GitHub Desktop.
/* global require, module */
var sass = require('node-sass');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var environment = process.env.EMBER_ENV;
var config = require('./config/environment')(environment);
var spriter = require('broccoli-svg-sprite');
module.exports = function(defaults) {
var srcFiles = {
srcDir: 'public/assets/images/svg',
include: ['**/*.svg'],
exclude: []
};
var svgOptions = {
dest: '.',
shape: {
spacing: { // Spacing related options
padding: 0, // Padding around all shapes
box: 'content' // Padding strategy (similar to CSS `box-sizing`)
},
},
mode: {
inline: true,
symbol: {
dest: 'assets/images',
bust: false,
render: {
css: {
dest: 'app.css'
}
},
prefix: '.svg-',
sprite: 'svg-sprites.svg',
example: false
},
}
};
var svgSpriter = new spriter(srcFiles, svgOptions);
var inlineContentOptions = {
'load-web-fonts-async': {
file: 'public/assets/scripts/load-web-fonts-async.js'
},
'first-script': {
file: 'public/assets/scripts/first-script.js'
},
'last-script': {
file: 'public/assets/scripts/last-script.js'
},
'async-css': {
file: 'public/assets/scripts/async-css.js'
},
'google-tag-manager': {
file: 'public/assets/partials/google-tag-manager.html',
postProcess: function(content) {
return content.replace(/\{\{GTM_ID\}\}/g, config.APP.googleTagManagerId);
}
},
'google-analytics': {
file: 'public/assets/partials/google-analytics.html',
postProcess: function(content) {
return content.replace(/\{\{GOOGLE_ANALYTICS_ID\}\}/g, config.APP.googleAnalyticsId).replace(/\{\{MIXPANEL_ID\}\}/g, config.APP.mixpanelId).replace(/\{\{LUCKY_ORANGE_ID\}\}/g, config.APP.luckyOrangeId).replace(/\{\{FACEBOOK_PIXEL_ID\}\}/g, config.APP.facebookPixelId).replace(/\{\{HUBSPOT_ID\}\}/g, config.APP.hubspotId).replace(/\{\{HOTJAR_ID\}\}/g, config.APP.hotJarId);
}
},
'facebook-app-id': {
file: 'public/assets/partials/facebook-app-id.html',
postProcess: function(content) {
return content.replace(/\{\{FACEBOOK_APP_ID\}\}/g, config.APP.facebookAppId);
}
}
};
var allInOneOptions = {
js: {
enabled: false
},
css: {
enabled: false
}
};
var isProductionLikeBuild = ['production', 'staging', 'whitelabel'].indexOf(environment) > -1;
var prependHost = ['production', 'whitelabel'].indexOf(environment) > -1 ? 'https://assets.timbuktutravel.com/' : 'https://staging-assets.timbuktutravel.com/'
if (isProductionLikeBuild) {
allInOneOptions['css']['enabled'] = true;
}
process.env.FASTBOOT_DISABLED = !isProductionLikeBuild;
var app = new EmberApp(defaults, {
'ember-cli-babel': {
includePolyfill: isProductionLikeBuild
},
babel: {
plugins: [
'transform-decorators-legacy',
'transform-class-properties'
]
},
'@ember-decorators/babel-transforms': {
disable: false
},
'ember-cli-uglify': {
uglify: {
output: {
semicolons: true
}
}
},
allInOne: allInOneOptions,
inlineContent: inlineContentOptions,
fingerprint: {
enabled: isProductionLikeBuild,
prepend: prependHost,
exclude: [
'images/layers-2x.png',
'images/layers.png',
'images/marker-icon-2x.png',
'images/marker-icon.png',
'images/marker-shadow.png',
'images/icon',
'images/icon_old',
'images/svg/activities',
'images/svg/faq',
'images/svg/lodge',
'images/svg/wildlife',
'images/svg/create-trip',
'images/svg/general',
'images/svg/logo',
'images/countries/solid-svg',
'images/countries/transparent-svg',
'images/continents/solid-svg'
],
extensions: ['js', 'css', 'png', 'jpg', 'gif', 'svg', 'txt']
},
sourcemaps: {
enabled: false,
},
minifyCSS: {
enabled: isProductionLikeBuild
},
minifyJS: {
enabled: isProductionLikeBuild
},
tests: process.env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,
hinting: process.env.EMBER_CLI_TEST_COMMAND || !isProductionLikeBuild,
sassOptions: {
includePaths: [
'app'
],
functions: {
theme: function() {
return new sass.types.String(config.theme);
}
}
},
outputPaths: {
app: {
css: {
'app': '/assets/app.css',
// 'fonts': '/assets/fonts.css'
}
}
}
});
process.env.FASTBOOT_DISABLED = !isProductionLikeBuild;
app.import('bower_components/pickadate/lib/themes/default.css');
app.import('bower_components/pickadate/lib/themes/default.date.css');
return app.toTree([svgSpriter]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment