2014-12-17 27 views
5

Gulp'u çalıştırdığımda sunucu mesajla başladı:/alamıyor. localhost: 3000/app/index.html öğesini işaret ettiğimde, site localhost: 3000/home adresine yönlendiriyor ve doğru çalışıyor. Bununla birlikte, sayfayı yeniden yüklediğimde, şu anlama geliyor: alamıyorum. şey cevapsız eğerbrowserSync's modRewrite, 'app/index.html' yolunda 'hilml5mode' için işe yaramaz

görmek için aşağıdaki yapılandırma inceleyin:

Yol erişimine:

var gulp = require('gulp'), 
nodemon = require('gulp-nodemon'), 
jshint = require('gulp-jshint'), 
browserSync = require('browser-sync') 
modRewrite = require('connect-modrewrite'); 

gulp.task('lint', function() { 
    gulp.src('app/js/*.js').pipe(jshint()); 
}); 

gulp.task('serve', function() { 
    browserSync({ 
     server: { 
      baseDir: "./", 
      middleware: [ 
       modRewrite([ 
        '!\\.\\w+$ /index.html [L]' 
       ]) 
      ] 
     } 
    }); 
}); 

gulp.task('default', ['lint', 'serve'], function() { 
    gulp.watch('app/js/*.js', ['lint', browserSync.reload]); 
}); 

açısal rota dosyası: Uygulamanın Bu benim gulpfile.js index.html

olduğunu /:

$urlRouterProvider.otherwise("/home"); 

    $stateProvider 
    .state('home', { 
     url: "/home", 
     templateUrl: "app/partials/home.html", 
     controller: 'HomeCtrl' 
    }) 
... 

Çok teşekkürler!

Github: https://github.com/yhjor1212/angular-fire-powder

cevap

1

kullanımı ModRewrite içinde bu kodu:

[ '^ (. [^] +) $ /index.html [L]']

Örnek:

gulp.task('serve', function() { 
    browserSync({ 
     server: { 
      baseDir: "./", 
      middleware: [ 
       modRewrite(['^([^.]+)$ /index.html [L]']) 
      ] 
     } 
    }); 
}); 
0

Ben şöyle, ModRewrite modülü ile ara katman kısmı sabit yudum ilgili değil ama Gruntfile.js ile bilmiyorum Maalesef:

var modRewrite = require('connect-modrewrite'); 

... 

grunt.initConfig({ 
    ... 
    browserSync: { 
     ... 
     options: { 
      server: { 
       middleware: [ 
        modRewrite(['!\.html|\.js|\.css|\.png$ /index.html [L]']) 
       ] 
      } 
     } 
... 

Mükemmel çalışır!

İlgili konular