I have a problem getting a local server with grunt-serve task to behave like a normal server should. My grunt.initConfig
object is like follows:
grunt.initConfig({
'serve': {
'path': '/Users/honkdonky/Desktop/testspace/angular',
},
'options': {
'port': '9999'
}
}
});
but when I request this link:
index.html there is not rendered. Instead what I see is a list of available files. The project should route requests to '/' by rendering index.html and routing as configured in angularjs module. Configuration of which is as follows:
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 。
I don't know if this could help. But I suggest you could try using gulp-webserver . It's pretty much easier to use and have a cool features such as livereload (automatically refresh the browser whenever there's any changes in the folder).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.