【问题标题】:Grunt connect with base html tagGrunt 与基本 html 标记连接
【发布时间】:2015-01-24 07:43:00
【问题描述】:

我正在为某人开发一个 angularjs 网站,他们将把它放在上面的网站是这样的

http://domain.com/newsite

所以为了让我的链接正常工作,我在头标签中添加了以下内容,以使链接在生产中正常工作

<base href="/newsite/" />

但是现在当我使用 grunt connect 时,由于该基本元素,没有任何效果。我想,当我在本地工作时,我可以将其注释掉,但我担心我会忘记把它放回去。感谢您的任何提示。

这是我的 grunt 文件的一部分

connect: {
        server: {
            options: {
                port: '9001',
                base: 'build/',
                protocol: 'http',
                hostname: 'localhost',
                livereload: true,
                open: {
                    target: 'http://localhost:9001',
                    callback: function() {}
                },
            }
        }
    },
    watch: {
        files: [
            '<%= app.root %>**/*',
            'Gruntfile.js'
        ],
        tasks: [ 'copy', 'less:dev' ],
        options: {
            reload: false,
            livereload: true,
            spawn: true
        }
    }

我检查的帖子没有给我任何答案:

【问题讨论】:

  • 你能发布你的 Gruntfile 的相关部分吗?
  • 你有没有尝试过这样的事情:` livereload: { options: { open: 'myapp.dev:9000/newsite', base: [ '.tmp', '' ] } `
  • 根据您的要求添加
  • 男人。 Grunt & Yeoman 有时会让人很困惑
  • 约曼跟我有什么关系?

标签: angularjs gruntjs grunt-contrib-connect


【解决方案1】:

我会将服务器选项的 livereload 部分更改为如下内容:

connect: {
    server: {
        options: {
            port: '9001',
            base: 'build/',
            protocol: 'http',
            hostname: 'localhost',
            livereload: true,
            open: 'http://localhost:9001/newsite/'
        }
    }
},

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 2013-08-05
    • 2010-10-14
    • 1970-01-01
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多