[英]ASP.NET Core magic new 'wwwroot' folder
So, Im confused with the use of the new "magic' wwwroot folder. I get the concept, it's a placeholder for all things "content" to be served to the client. But when it comes to bundle/minify/ect it seems to do more harm than good. Since the 'wwwroot' folder is an actual folder, it has a path. But, you never referenced it like you would any other folder. So, when trying to request content from a URL I would say " http://myURL/images/imgone.img " but the image is inside the wwwroot/images folder. However, when I need to bundle I have to specify the folder. then, during minification it add the "wwwroot" to the reference inside CSS. I feel like im stuck in a circle here. 因此,我对新的“魔术” wwwroot文件夹的使用感到困惑。我得到了这个概念,它是将所有“内容”都提供给客户端的占位符,但是当涉及捆绑/缩小/提取时,似乎弊大于利。由于“ wwwroot”文件夹是实际文件夹,因此它具有路径。但是,您从未像其他任何文件夹一样引用它。因此,当尝试从URL请求内容时,我会说“ http ://myURL/images/imgone.img “,但图像位于wwwroot / images文件夹中。但是,当我需要捆绑时,我必须指定该文件夹。然后在缩小过程中,将“ wwwroot”添加到内部的引用中CSS,我感觉自己陷入了一个圆圈。
How has anyone dealt with this new "magic" folder from MS? 有人怎么从MS处理这个新的“ magic”文件夹?
UPDATE: I have an old site, using DurandalJS, which in turn uses RequireJS. 更新:我有一个旧站点,使用DurandalJS,而后者使用RequireJS。 I have a gulp task (gulp-durandal) that bundles the JS files (My APP files and Durandal) into one single JS file.
我有一个gulp任务(gulp-durandal),它将JS文件(我的APP文件和Durandal)捆绑到一个单独的JS文件中。 I use the bundle-minifier plug in to handle bundling the rest of the JS files (3rd party, ect).
我使用bundle-minifier插件处理捆绑其余JS文件(第三方等)。 Problem is, inside the main.js file might look like this.
问题是,main.js文件内部可能看起来像这样。
require.config({
catchError: {
define: true
},
waitSeconds: 200,
urlArgs: "v=" + (new Date()).getTime(),
paths: {
//text: "../Scripts/lib/require/text",
durandal: "../Scripts/lib/durandal/js",
plugins: "../Scripts/lib/durandal/js/plugins",
transitions: "../Scripts/lib/durandal/js/transitions",
async: "../Scripts/lib/require/async",
services: "services",
}
}); });
but if the scripts folder is located inside the "wwwroot" folder, it cannot be found. 但是如果脚本文件夹位于“ wwwroot”文件夹中,则找不到该文件夹。 But I cannot specify the folder directly, because then when running development and requesting each file, it will try and bring it down from http://myURL/wwwroot/scripts/ect
但是我无法直接指定文件夹,因为在运行开发并请求每个文件时,它将尝试从http:// myURL / wwwroot / scripts / ect中删除它
The folder wwwroot
is for your client historically called "static content". 文件夹
wwwroot
用于您的客户,历史上称为“静态内容”。 You can rename wwwroot
if you would like. 您可以根据需要重命名
wwwroot
。 Nowadays it is kind of logical separation between the app's client-side content and server-based code (which should not be inside wwwroot to prevent server-side code from being leaked. 如今,这是应用程序的客户端内容和基于服务器的代码之间的逻辑分离(不应将其放在wwwroot中,以防止服务器端代码被泄漏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.