[英]grunt serve deleting reference to openlayers.js in index.html
[英]grunt-serve doesn't serve index.html with '/' request
我在讓帶有 grunt-serve 任務的本地服務器表現得像普通服務器一樣時遇到問題。 我的grunt.initConfig
對象如下:
grunt.initConfig({
'serve': {
'path': '/Users/honkdonky/Desktop/testspace/angular',
},
'options': {
'port': '9999'
}
}
});
但是當我請求此鏈接時:
index.html 沒有呈現。 相反,我看到的是可用文件列表。 該項目應該通過呈現 index.html 並按照 angularjs 模塊中的配置路由來將請求路由到“/”。 其配置如下:
phoneApp.config(['$routeProvider',
function($routeProvider) {
$routeProvider.
when('/phones', {
templateUrl: 'phone-list.html',
controller: 'PhoneListCtrl'
}).
when('/phones/:phoneId', {
templateUrl: 'phone-detail.html',
controller: 'PhoneDetailCtrl'
}).
otherwise({
redirectTo: '/phones'
});
}
]);
grunt-serve包用於運行任務和提供文件,它不能渲染 / 到 index.html,如果你需要一個 web 服務器,你可以使用grunt-contrib-connect 。
我不知道這是否有幫助。 但我建議你可以嘗試使用gulp-webserver 。 它使用起來非常簡單,並且具有很酷的功能,例如 livereload(只要文件夾中有任何更改,就會自動刷新瀏覽器)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.