1
votes

I'm trying to use ExpressJS with the scaffolded version of Angular that is installed by the AngularJS Yeoman generator. I'd prefer to use the scaffolded version created by the Yeoman Team rather than use the angular-fullstack or express versions. So I manually installed Express JS in a server folder within my project.

-app //Angular files are here
-server //Node JS files are here

I think the connect server is currently being used instead of Express. Is there a way to change the grunt file to require Express instead?

I think this is the relevant code in my gruntfile.js:

// The actual grunt server settings
connect: {
  options: {
    port: 9000,
    // Change this to '0.0.0.0' to access the server from outside.
    hostname: 'localhost',
    livereload: 35729
  },
  livereload: {
    options: {
      open: true,
      middleware: function (connect) {
        return [
          connect.static('.tmp'),
          connect().use(
            '/bower_components',
            connect.static('./bower_components')
          ),
          connect().use(
            '/app/styles',
            connect.static('./app/styles')
          ),
          connect.static(appConfig.app)
        ];
      }
    }
  }
1

1 Answers

0
votes

Configuration

Yeoman generated projects can be further tweaked according to your needs by modifying project files appropriately.

You can change the app directory by adding a appPath property to bower.json. For instance, if you wanted to easily integrate with Express.js, you could add the following:

{
  "name": "yo-test",
  "version": "0.0.0",
  ...
  "appPath": "public"
}

This will cause Yeoman-generated client-side files to be placed in public.

Note that you can also achieve the same results by adding an --appPath option when starting generator:

yo angular [app-name] --appPath=public


I would say that you went too far with generating your project, please read carefully documentation for more details.