Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow build:debug and build:dist builds to run from file protocol #364

Closed
shainegordon opened this issue Dec 10, 2013 · 11 comments
Closed

Comments

@shainegordon
Copy link

My current ember app (running in node-webkit) is built on an old pre jj-abrams-resolver EAK. this runs perfectly in my browser and nwk using the file:// protocol, eg from tmp/public/index.html

I see there is a lot of progress on EAK, and thought I would try it out. however, i noticed now that file:// no longer works. I see this is because vendor is now not placed in to "tmp/public".

would be really nice to be able to run from file again (ember js + node webkit = amazing cross platform deskop apps, but have to run in file protocol)

@stefanpenner
Copy link
Owner

@shainegordon this sounds reasonable, would you like to try your hand at a proposal or pr?

@shainegordon
Copy link
Author

@stefanpenner truth be told, i am very green when it comes to javascript build processes, but I am definitely keen :)

I assume that this will entail a custom grunt task and optional build config

@stefanpenner
Copy link
Owner

maybe @MajorBreakfast or someone else can help give you pointers :)

@MajorBreakfast
Copy link
Contributor

Using the integrated development sever is best practice because features like push state routing can't work without it. That being said it is certainly possible to modify the grunt file so that it assembles your app completely:

  • Gruntfile.js Adding the 'copy:assemble' task after 'concurrent:buildDebug' in the build:debug task should do the trick.

Alternative solution:
File urls stop working as soon as you deploy your apps. Your browser doesn't allow them. Consider putting any static files that you need into the public/ folder. If you need something more elaborate you could use a node server on a different port (like 9000). Use the node server for serving any files you might need at runtime. This middleware pumps all requests through to port 8000 (app kit) during development. This way app kit's setup remains untouched.

express = require 'express'
path = require 'path'
request = require 'request'
livereload = require('connect-livereload')()

publicDirectory = path.join __dirname, '../../public'
indexHTML = path.join publicDirectory, 'index.html'
servePublicDirectory = express.static publicDirectory

###
  Development: Pipe through to localhost:8000
  Production: Serve from `public/` directory, index.html if file doesn't exist
###
module.exports = (req, res, next) ->
  if req.app.get('env') is 'production'
    servePublicDirectory req, res, -> res.sendfile indexHTML
  else
    livereload req, res, ->
      request('http://localhost:8000' + req.path)
      .on('error', (err) ->
        res.send 500, message: 'Grunt server is not running.'
      )
      .pipe(res)

Note: It's CoffeeScript, use js2coffee.org if you need JS. I'm using the node packages: request, express and connect-livereload

@shainegordon
Copy link
Author

@MajorBreakfast Thank you very much, option 1 will suit me very nicely.

I understand that running from file:// is not best practice, however, when building apps to run on the desktop with something like node-webkit, I have no choice.

@MajorBreakfast
Copy link
Contributor

I understand. I think it's reasonable that at some point in the future we'll move everything to the tmp directory again. You're right: It could come in handy for this and maybe also for more. The mid term plan is to move away from grunt as the main build tool. Something much faster and intelligent is currently in the works by @joliss.

@stefanpenner
Copy link
Owner

@MajorBreakfast phonegap users will likely be at file:// as well.

@stefanpenner
Copy link
Owner

i think it would be easiest if we just support a configurable "base path"

@MajorBreakfast got time to give it a go?

@MajorBreakfast
Copy link
Contributor

Okay I'll look into it

@dcrec1
Copy link

dcrec1 commented Feb 28, 2014

For this problem, you can use the app protocol and reference your index.html like:

"main": "app://whatever/index.html"

See https://github.com/rogerwang/node-webkit/wiki/App%20protocol

@fsmanuel
Copy link
Collaborator

fsmanuel commented Apr 8, 2014

closing in favor of ember-cli/ember-cli#292

@fsmanuel fsmanuel closed this as completed Apr 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants