2

I have an ember-cli based app which needs to be integrated into an existing java/JSP app. For this to happen I need to generate a JSP file with js/css fingerprinted URLs which are generated by ember-cli/broccoli-asset-rev.

This is working fine for a html file and I can set it use a JSP file by changing my Brocfile.js to include:

var app = new EmberApp({
  outputPaths: {
    app : {
      html: 'index.jsp'
    }
  }
});

but this prevents ember serve working as it uses the index.jsp as the html file. Is it possible to have both generated?

Matt
  • 41
  • 5
  • Maybe knowing about the differences between the `jsp` and `html` files will allow us to find a different approach. – givanse May 19 '15 at 16:05
  • The differences between the HTML and JSP files are that the JSP file injects some variables into meta tags which are populated by the server at run time. – Matt May 19 '15 at 16:22

3 Answers3

1

After trying many things I have come up with two solutions, both have drawbacks. The first is to use make a new broccoli tree and merge it with he app tree then explicity run broccoli-asset-rev on the resulting tree. The downside of this is that the mustache does not get hydrated, this is useful for outputting config. This would look something like:

//Brocfile.js

var mergeTrees = require('broccoli-merge-trees');
var funnel = require('broccoli-funnel');
var assetRev = require('broccoli-asset-rev');
var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var jspTree;

var app = new EmberApp({
  fingerprint: {
    enabled: false
  },
  storeConfigInMeta: false
});


jspTree = funnel('app', {
  files: ['index.jsp']
});

module.exports = assetRev(mergeTrees([appTree = app.toTree(), jspTree]), {
  extensions: ['js', 'css'],
  replaceExtensions: ['jsp', 'html']
});

The other solution is the override a private api method in ember-cli which builds the tree for the index. This solution does let the mustache get hydrated but relies on a private method. You can find details here and here

Matt
  • 41
  • 5
0

How about adding symbolic link?

ln -s index.jsp index.html
givanse
  • 14,503
  • 8
  • 51
  • 75
0

Depending on what build tool you're using in your project, I'd probably recommend something like the following:

  1. Put some placeholder sections in your index.html.
  2. Copy index.jsp to index.jsp.tmp.
  3. Copy in code from index.jsp into your placeholder sections.
  4. Move index.jsp.tmp back to index.jsp and clean up.

You might consider something like gulp-replace to do the work.

typeoneerror
  • 55,990
  • 32
  • 132
  • 223
  • I'm sure there are a lot of tools for that work flow. How do you integrate it with Ember CLI (Broccoli)? – givanse May 19 '15 at 16:03