2

My angular Application works fine with grunt serve,when i test with grunt serve:dist it's throwing an error.(for particular url)

i have open url it is working fine with this url.

After grunt serve:dist the url is not working getting 404 error.

Except that url total application working with grunt serve:dist.

Thanks in advance

grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'wiredep',
      'concurrent:server',
      'autoprefixer:server',
      'connect:livereload',
      'watch'
    ]);
  });

  grunt.registerTask('server', 'DEPRECATED TASK. Use the "serve" task instead', function (target) {
    grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
    grunt.task.run(['serve:' + target]);
  });

  grunt.registerTask('test', [
    'clean:server',
    'wiredep',
    'concurrent:test',
    'autoprefixer',
    'connect:test',
    'karma'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'wiredep',
    'useminPrepare',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngAnnotate',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'filerev',
    'usemin',
    'htmlmin',
    'copy:images',
    'copy:ngAutocompleteScript',
    'copy:languages',
    'copy:resources'
  ]);

  grunt.registerTask('default', [
    'newer:jshint',
    'test',
    'build'
  ]);
Ajay
  • 307
  • 4
  • 14
  • You need to compile your app into your dist before serving. – Zooly Sep 18 '17 at 07:35
  • @Zooly I am doing that – Ajay Sep 18 '17 at 08:26
  • @Zooly done that – Ajay Sep 18 '17 at 09:46
  • @Zooly after grunt serve:dist the url is not getting(URL not found error) – Ajay Sep 18 '17 at 10:09
  • 1
    It's very difficult to provide an answer to your question as you have not provided any code examples of your `Gruntfile.js`. However, this [post](https://stackoverflow.com/questions/18345179/how-to-run-grunt-server-in-dist-directory-instead-of-app-directory) might help, particularly this [answer](https://stackoverflow.com/questions/18345179/how-to-run-grunt-server-in-dist-directory-instead-of-app-directory#answer-21285745) – RobC Sep 18 '17 at 10:09
  • @RobC already have the same code in my file but it is not working.and i updated the Gruntfile.js file – Ajay Sep 18 '17 at 10:41
  • @Ajay - Did you ever resolve this? I am running into the same problem. Grunt serve works fine but with the dist i get 404 for pretty much every html/js file. I used yo angular to scaffold my app. – reedb89 Sep 26 '17 at 21:46
  • @reedb89 No man if have solution please give me – Ajay Sep 27 '17 at 05:48
  • @reedb89 we also using same yo angular – Ajay Sep 27 '17 at 06:34
  • @Ajay - I was able to fix a few things by making sure the file references were in the proper comments on the index.html. I also made adjustments to my paths in my app.js (ie form /views/page.html to views/page.html). This seemed to help but i am still facing issues for about 50% of the pages. – reedb89 Sep 27 '17 at 15:06
  • @reedb89 okay i will do this. – Ajay Oct 03 '17 at 05:39
  • @reedb89 still not working if you have solution give me – Ajay Oct 04 '17 at 05:50

0 Answers0