适用于 ASP.NET MVC 3 的 Tincr

问题描述 投票:0回答:1

我正在尝试在 Chrome 中使用 tincr 扩展。它允许您刷新 CSS 和 JavaScript,而无需再次重新加载页面。我在让它工作时遇到了一些麻烦。

我的设置

源码根目录:

C:\dev\tfs\MyApp\Development Branches\3.3.0.0\Presentation\MyApp
.

IIS网站目录指向上面的根目录。上面文件夹路径下的 Scripts 目录包含我正在更改的 js 文件。

我创建了一个tincr.json文件,放在根目录下

tincr.json

{
    "toFile" : [],
    "fromFile" : [
        {"from": "C:\\\\dev\\\\tfs\\\\MyApp\\\\Development Branches\\\\3.3.0.0\\\\Presentation\\\\MyApp\\\\Scripts\\\\(.+\\.js)",
         "to": "http://localhost/MyApp/Scripts/$1"}
    ]
}

这是正确的吗?我怎样才能让 tincr 与 ASP.NET MVC 3 一起工作?

asp.net-mvc-3 google-chrome-devtools livereload
1个回答
1
投票

玩玩和阅读谷歌群组和其他网站后,我拼凑了以下内容

  • Tincr 不适用于 Windows 中的查询参数(例如 common.js?var=1 将失败)
  • 您需要注意附加到来自对 ajax 代码的引用的 js 文件的 url 的 ajax 查询。使用 Fiddler 并观察 URLS。我必须确保将 js 文件添加到 _Layout.cshtml 文件,然后它会在没有查询参数的情况下出来。

我在我的网站上放了更详细的如何使用 Tincr http://aboutdev.wordpress.com/2013/01/26/using-tincr-with-asp-net-mvc-in-windows-7/ 但是这是你需要的。

我使用的tincr.js文件如下所示:

{
    "toFile" : [],
    "fromFile" : 
    [
        {
            "from": "\\\\Scripts\\\\([a-zA-Z]+)\\.js",
            "to": "/MyApp/Scripts/$1.js"
        }
    ]
}

此文件不会更新磁盘上的文件,因为未填写“tofile”。 该文件将在您放置 tincr.json 文件的根目录下的 Scripts 目录中查找文件。

希望这对您在项目中使用 Tincr 有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.