虚拟主机不支持 .less 文件扩展名

发布于 2024-12-01 07:24:37 字数 321 浏览 4 评论 0原文

我在我的 MVC 应用程序上使用 lesscss.org 的样式。

它工作得很好,但不幸的是我的网络主机不支持 .less 文件扩展名,他们也不会添加支持。

虽然 LessCSS 使用 JavaScript,但肯定有一种方法可以将我的 CSS 文件从 site.less 重命名为 site.css,并更改 JavaScript 以使用 .css 扩展名而不是 .less 扩展名。

请注意,我没有使用 dotLess,并且在发布之前进行编译也不是我想要的。

I am using lesscss.org's styles on my MVC application.

It works great, but unfortunately my web host does not support .less file extensions, neither will they add support.

Seeing though LessCSS makes use of JavaScript, surely there must be a way to rename my CSS file from site.less to site.css and change the JavaScript to make use of the .css extension instead of the .less extension.

Please note I am not using dotLess, and compiling prior to release is also not what I am looking for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

江湖正好 2024-12-08 07:24:37

终于成功了。

我所要做的就是修改我的 MVC web 应用程序web.config 并添加以下内容:

<system.webServer>
  ...
  <staticContent>
    <mimeMap fileExtension=".less" mimeType="text/css" />
  </staticContent>
</system.webServer>

我将网站重新发布到我的托管提供商 afrihost,它的墙工作得很好。

Finally got it working.

All i had to do is modify my web.config of my MVC web application and add the following:

<system.webServer>
  ...
  <staticContent>
    <mimeMap fileExtension=".less" mimeType="text/css" />
  </staticContent>
</system.webServer>

I re-published the site to my hosting provider afrihost, and it wall worked perfectly.

月亮邮递员 2024-12-08 07:24:37

该脚本似乎只寻找 stylesheet/less rel。据我所知,文件扩展名并不重要。

为了澄清,将 styles.less 重命名为 styles.css 并使用以下代码应该可以工作:

<link rel="stylesheet/less" type="text/css" href="styles.css">
<script src="less.js" type="text/javascript"></script>

The script appears to only be looking for the stylesheet/less rel. As far as I can tell, the file extension doesn't matter.

To clarify, renaming styles.less to styles.css and using the following code should work:

<link rel="stylesheet/less" type="text/css" href="styles.css">
<script src="less.js" type="text/javascript"></script>
奶茶白久 2024-12-08 07:24:37

只需在本地转换为 css,然后上传即可。

$ lessc styles.less > styles.css

从使用页面:
http://lesscss.org/#-client-side-usage

你可以通过 < code>-x 用于缩小。

Simply convert to css locally before you upload it.

$ lessc styles.less > styles.css

From the usage page:
http://lesscss.org/#-client-side-usage

You can pass -x for minification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文