0

I am running yo --v 1.1.2 and angular-generator --v 0.10.0 to create a new app,

Enabling HTML5Mode was a little bit tricky since I needed to use server rewrites to avoid 404 errors when I hit the url in the browser.

So I followed the instructions in this thread and apparently it isn't working on the latest version of angular-generator. it works great on the dev environment, but not on the production dist directory, asset files in dist are not loaded properly and I get 404.

grunt serve #works great
grunt build #I get 404 on asset files and the baseurl is not correct.

Any ideas on how to make it work ?

This is grunt connect I used

    // 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,
    // Modrewrite rule, connect.static(path) for each path in target's base
    middleware: function (connect, options) {
      var optBase = (typeof options.base === 'string') ? [options.base] : options.base,
          middleware = [require('connect-modrewrite')(['!(\\..+)$ / [L]'])]
            .concat(optBase.map(function (path) { 
              if (path.indexOf('rewrite|') === -1) {
                return connect.static(path);
              } else {
                path = path.replace(/\\/g, '/').split('|');
                return  connect().use(path[1], connect.static(path[2]))
              }
            }));

      return middleware;
    }
  },
  livereload: {
    options: {
      open: true,
      base: [
        '.tmp',
        'rewrite|/bower_components|./bower_components',
        'rewrite|/app/styles|./app/styles', // for sourcemaps
        '<%= yeoman.app %>'
      ]
    }
  },
  test: {
    options: {
      port: 9001,
      base: [
        '.tmp',
        'test',
        'rewrite|/bower_components|./bower_components',
        'rewrite|/app/styles|./app/styles',
        '<%= yeoman.app %>'
      ]
    }
  },
  dist: {
    options: {
      base: '<%= yeoman.dist %>'
    }
  }
},
Community
  • 1
  • 1
Evan Lévesque
  • 3,115
  • 7
  • 40
  • 61

0 Answers0