Skip to content

Instantly share code, notes, and snippets.

@bgentry
Created February 10, 2017 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgentry/752c1e722ea81041b35bb1a10021ea0d to your computer and use it in GitHub Desktop.
Save bgentry/752c1e722ea81041b35bb1a10021ea0d to your computer and use it in GitHub Desktop.
attempt to make graphql files available as ember imports
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var Filter = require('broccoli-filter');
var Funnel = require('broccoli-funnel');
module.exports = function(defaults) {
var env = EmberApp.env();
var isProductionLikeBuild = ['production', 'staging'].indexOf(env) > -1;
var ENV = defaults.project.config(env);
// necessary to avoid using non-prod builds of redux
if (isProductionLikeBuild) {
process.env.NODE_ENV = 'production';
}
var app = new EmberApp(defaults, {});
var extras = [];
if (!isProductionLikeBuild) {
GraphqlModule.prototype = Object.create(Filter.prototype)
GraphqlModule.prototype.constructor = GraphqlModule
function GraphqlModule (inputTree, options) {
if (!(this instanceof GraphqlModule)) return new GraphqlModule(inputTree, options)
Filter.call(this, inputTree, options)
options = options || {};
}
GraphqlModule.prototype.extensions = ['graphql']
GraphqlModule.prototype.targetExtension = 'js'
GraphqlModule.prototype.processString = function (string) {
return "export default `" + string + "`;";
}
var graphqlAssets = new Funnel(
GraphqlModule('tests/fixtures')
);
extras.push(graphqlAssets);
}
return app.toTree(extras);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment