【发布时间】:2017-01-10 16:58:56
【问题描述】:
我正在尝试设置我的 grunt 服务器以允许推送状态。
在无数次谷歌搜索和阅读 SO 帖子之后,我无法弄清楚如何做到这一点。
我不断收到如下错误。
有人知道如何解决这个问题吗?
未找到“连接”目标。警告:任务“连接”失败。使用 --force 继续。
在我看来,我在下面定义了targets
open: {
target: 'http://localhost:8000'
}
完整代码如下:
var pushState = require('grunt-connect-pushstate/lib/utils').pushState;
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
options: {
hostname: 'localhost',
port: 8000,
keepalive: true,
open: {
target: 'http://localhost:8000'
},
middleware: function (connect, options) {
return [
// Rewrite requests to root so they may be handled by router
pushState(),
// Serve static files
connect.static(options.base)
];
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify'); // Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-connect'); // Load the plugin that provides the "connect" task.
// Default task(s).
grunt.registerTask('default', [ 'connect']);
};
【问题讨论】:
-
这样的情况是我切换到
gulp的原因。此外,该软件包已被贬低。 -
@MichaelCole 遇到了与
gulp相同的问题!关于如何使用gulp的任何想法?看来连谷歌都不知道! -
对不起,我帮不上忙。这是相当古老的技术——我已经构建了 MEAN 应用程序并且不需要它。你确定你需要它吗?
-
我想要一种在本地服务器上允许推送状态的方法。你知道解决这个问题的其他方法吗?我不是专家
标签: javascript gruntjs