标签: bundle

ASP.NET MVC 4脚本捆绑在部署时导致错误

@Scripts.Render()当我没有捆绑脚本时,我的网站在localhost上正常工作,但是当我部署到我的服务器时,捆绑的Javascript必须包含错误,因为我页面上的所有Javascript都停止工作.

这是我的捆绑代码:

        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js",
                    "~/Scripts/jquery-migrate-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                        "~/Scripts/jquery-ui-{version}.js",
                        "~/Scripts/jquery-ui.unobtrusive-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));

            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                        "~/Content/themes/base/jquery.ui.core.css",
                        "~/Content/themes/base/jquery.ui.resizable.css",
                        "~/Content/themes/base/jquery.ui.selectable.css",
                        "~/Content/themes/base/jquery.ui.accordion.css",
                        "~/Content/themes/base/jquery.ui.autocomplete.css",
                        "~/Content/themes/base/jquery.ui.button.css",
                        "~/Content/themes/base/jquery.ui.dialog.css",
                        "~/Content/themes/base/jquery.ui.slider.css",
                        "~/Content/themes/base/jquery.ui.tabs.css",
                        "~/Content/themes/base/jquery.ui.datepicker.css",
                        "~/Content/themes/base/jquery.ui.progressbar.css",
                        "~/Content/themes/base/jquery.ui.theme.css"));
        }
Run Code Online (Sandbox Code Playgroud)

这是我的渲染代码:

@Styles.Render("~/Content/css")
@Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/modernizr")
Run Code Online (Sandbox Code Playgroud)

有人可以解释部署时我的Javascript可能会发生什么吗?

谢谢,亚历克斯.

javascript c# bundle asp.net-mvc-4 razor-2

19
推荐指数
3
解决办法
2万
查看次数

MVC4 Bundles返回404

我有一个项目,当你从visual studio中运行时,它可以与捆绑一起使用.但是,在进行部署之后,捆绑处理程序似乎永远不会选择路由.它最终转到静态文件处理程序,返回404响应.

有任何想法吗?我在IIS下的网站bin中看到了优化程序集.

它使用4.0应用程序池和集成模式.

我想知道是否有人有任何想法或建议?

谢谢

-----根据问题更新-----

VS2012

targetFramework = "4.5"

我还在视图中添加了一些代码,以显示哪些模块已加载,我可以看到其中列出的bundle模块.

BundleConfig是使用Internet Application MVC4项目模板时提供的默认值.

该站点正在部署到根目录中.奇怪的是,当我设置EnableOptimizations = true时(由于通过visual studio F5在调试模式下运行),它完美无缺!我可以导航到content/css,它会吐出组合的CSS.

我部署它,其他一切工作,但捆绑!

c# bundle asp.net-mvc-4

19
推荐指数
3
解决办法
1万
查看次数

不要缩小ASP .NET MVC 4 BundleConfig中的某些文件

我不想缩小我在ASP .NET MVC 4解决方案中使用的所有文件.例如,我在BundleConfig.cs中有这个:

bundles.Add(new StyleBundle("~/CSS/bootstrap").Include(
    "~/Content/Bootstrap/body.css",
    "~/Content/Bootstrap/bootstrap-responsive.css",
    "~/Content/Bootstrap/bootstrap-mvc-validation.css",
    "~/Content/Bootstrap/bootstrap-theme.css",
    "~/Content/Bootstrap/bootstrap.css"
    ));

...
Run Code Online (Sandbox Code Playgroud)

为了缩小它,我当然使用:

BundleTable.EnableOptimizations = true;
Run Code Online (Sandbox Code Playgroud)

所以它很棒.

但是现在,除了一个捆绑包之外,我怎么能缩小我的所有文件?我有一个捆绑的问题,删除了一些CSS类,并希望不缩小这一个.

任何帮助将不胜感激.

asp.net-mvc bundle asp.net-mvc-4 asp.net-optimization

19
推荐指数
3
解决办法
7829
查看次数

什么是捆绑安装 - 部署和捆绑包之间的区别

我知道他们都把宝石放在你的应用程序的不同位置,但似乎捆绑安装 - 部署做得更彻底.我可以将它创建的供应商/包目录添加到版本控制并完成吗?

gem bundle ruby-on-rails bundler ruby-on-rails-3

18
推荐指数
3
解决办法
2万
查看次数

如何撤消vendor/gems bundle install

我跑了bundle install vendor/gems,所有的宝石都按预期保存到了gems目录,但当我删除它们时

rm -rf vendor/gems

rails s
 Could not find rake-0.9.2.2 in any of the sources
 Run `bundle install` to install missing gems.
Run Code Online (Sandbox Code Playgroud)

我需要再次运行bundle install,所有的gem vendor/gems再次安装.有没有办法让这种行为停止,只是安装,因为我以前使用我的.rvmrc文件,而不是将gem包装在vendor/gems目录中

bundle ruby-on-rails bundler rvm ruby-on-rails-3

18
推荐指数
1
解决办法
4874
查看次数

在MVC 4中运行时动态捆绑和缩小

我想知道是否有人可以帮助我使用MVC 4附带的新优化命名空间进行捆绑和缩小.我有一个Multitenant应用程序,我想根据每个用户的设置决定应该加载哪些js文件.一种方法是预先创建所有捆绑包并根据用户的设置更改resolvebundleurl的虚拟路径,但这感觉不是真正正确的方式.另外,我在基于用户设置的cshtml视图中有动态css,我想在运行时缩小它.

有什么建议?在其他问题中我也看到很多反应来检查Requestreduce,但它们都来自同一个用户.

处理这两种情况的最佳方法是什么?

提前致谢!

asp.net optimization bundle asp.net-mvc-4 asp.net-optimization

18
推荐指数
3
解决办法
2万
查看次数

方法"Bundle.Include"(在System.Web.Optimization中与ASP.NET MVC一起使用)是否会抛出异常而不是默默地忽略丢失的文件?

如果缺少javascript或css文件,是否可能以某种方式抛出异常?

我已尝试使用下面的代码,但它从未抛出异常......

    public class BundleConfig {
    public static void RegisterBundles(BundleCollection bundles) {  
        ....

        bundles.Add(new ScriptBundle("~/bundles/something").Include("~/Scripts/nonExistingFile.js"));
        // I would like the above usage of Include method with 
        // a non-existing file  to throw an exception to make it 
        // obvious that an expected file is missing ...
        // but since it does not I tried to implement a method as below ...
        ...
        AssertThatAllFilesExist(bundles);
        // but unfortunately an exception is never thrown but when 
        // iterating the files in the method …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc bundle

18
推荐指数
2
解决办法
2202
查看次数

资产目录:访问不同文件夹中具有相同名称的图像

有一个images.xcassets在我的项目,它包含一个icons文件夹,两个子文件夹(firstFolder,secondFolder)与图像.我的两个子文件夹都有相同数量的图标和相同的图标名称(针对我的应用程序的不同主题).

所以我正在寻找:我需要从我的包中获取所需的图标(当前主题).

我试过这样的事情:

NSBundle* bundle = [NSBundle bundleForClass:[self class]];
NSString *imageName = [bundle.bundlePath stringByAppendingPathComponent:@"icons/firstFolder/neededIcon"];
Run Code Online (Sandbox Code Playgroud)

这是行不通的.

xcode bundle assets objective-c ios

18
推荐指数
1
解决办法
5025
查看次数

iOS框架捆绑的路径

我正在研究iOS的框架,它带有一些数据文件.要将它们加载到Dictionary我做这样的事情:

public func loadPListFromBundle(filename: String, type: String) -> [String : AnyObject]? {
    guard
       let bundle = Bundle(for: "com.myframework")
       let path = bundle.main.path(forResource: filename, ofType: type),
       let plistDict = NSDictionary(contentsOfFile: path) as? [String : AnyObject]
    else { 
       print("plist not found")
       return nil 
    }

    return plistDict
}
Run Code Online (Sandbox Code Playgroud)

如果我在带有框架的游乐场中使用它,它可以按预期工作.

但是,如果我使用嵌入在应用程序中的框架,它不再起作用,"路径"现在指向应用程序的捆绑,而不是框架.

如何确保访问框架的捆绑包?

编辑:上面的代码驻留在框架中,而不是在应用程序中.

EDIT2:上面的代码是一个实用函数,不是结构或类的一部分.

frameworks bundle ios swift swift3

18
推荐指数
3
解决办法
1万
查看次数

mimemagic 安装错误:“在 Windows 上无法在以下位置找到 MIME 类型数据库...”

尝试mimemagic 0.3.10在 Ruby on Rails 项目中安装时遇到以下错误。注意,它是在Windows环境下运行的。这是最相关的错误堆栈跟踪:

Fetching mimemagic 0.3.10
Installing mimemagic 0.3.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby26/lib/ruby/gems/2.6.0/gems/mimemagic-0.3.10/ext/mimemagic
C:/Ruby26/bin/ruby.exe -rrubygems
C:/Ruby26/lib/ruby/gems/2.6.0/gems/rake-13.0.6/exe/rake
RUBYARCHDIR\=C:/Ruby26/lib/ruby/gems/2.6.0/extensions/x86-mingw32/2.6.0/mimemagic-0.3.10    
RUBYLIBDIR\=C:/Ruby26/lib/ruby/gems/2.6.0/extensions/x86-mingw32/2.6.0/mimemagic-0.3.10     
rake aborted!
Could not find MIME type database in the following locations:
["/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/homebrew/share/mime/packages/freedesktop.org.xml",
"/opt/local/share/mime/packages/freedesktop.org.xml",
"/usr/share/mime/packages/freedesktop.org.xml"]

Ensure you have either installed the shared-mime-info package for your
distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to
the location
of that file.

This gem might be installed …
Run Code Online (Sandbox Code Playgroud)

ruby mime bundle rubygems ruby-on-rails

18
推荐指数
1
解决办法
1万
查看次数