无法使用Web Compiler 2015编译更少的嵌套文件 [英] Can't compile nested less files with Web Compiler 2015

查看:72
本文介绍了无法使用Web Compiler 2015编译更少的嵌套文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,在为Visual Studio 2015安装Web Essentials 2015时,我感到非常惊讶,因为它不再包含更少的编译器了: "Web Essentials 2015不再包含用于捆绑和最小化JS,CSS和HTML文件以及编译LESS的功能".

well, I was quite surprised when installing Web Essentials 2015 for Visual Studio 2015 that it didn't include a less compiler anymore: "Web Essentials 2015 no longer contains features for bundling and minifying of JS, CSS and HTML files as well as compiling LESS".

在使用Visual Studio 2013之前,一切都运行良好.因此,我下载了Web Compiler 2015,因为它是Mads Kristensen的新编译器.但是,在将所有需要编译的文件添加到Compilerconfig.json后,我在编译时出现错误,它不再识别我的变量或我的mixins!

Everything worked fine before with Visual Studio 2013. So I downloaded Web Compiler 2015, as it is the new compiler from Mads Kristensen. But, after adding all the needed files to be compiled to the compilerconfig.json, I have an error on compilation that it doesn't recognize my variables anymore nor my mixins!

这是我的网站.less:

Here's my site.less:

/* Colors and common variables */
@import "Colors";
@import "Variables";

/* Reseting default values for all internet browsers */
@import "Reset.css";

/*  BootStrap   */
@import "../../../Content/bootstrap/bootstrap.less";

/* Basic mixins */
@import "mixins/Generic_Mixin.less";
@import "mixins/Controls.less";
@import "mixins/Images.less";
@import "mixins/Navigation.less";
@import "mixins/Text.less";

/* Website specific classes */
@import "Controls.less";
@import "Footer.less";
@import "Header.less";
@import "Images.less";
@import "Text.less";
@import "combobox.less";

@import "Sitemaster.less";

这是我的许多错误之一:

And here's one of my many errors :

variable @font-size-base is undefined on line 49 in file
'C:\Users\(...)\Site.WebApp\App_Themes\Default\Styles\mixins\Variables.less':

请,我对所有这些都不了解,有人会为我解答吗?谢谢.

Please, I don't understand anything to all of this, anyone would have an answer for me ? Thx.

推荐答案

我遇到了同样的问题. Web编译器在许多方面都失败了,并且变通方法是杂乱无章的,并且不容易得到支持.将来的Web编译器版本可能会有用,但是我得出的结论是,仅切换到更成熟的不那么编译工具是很麻烦的.

I had the same problem. Web Compiler failed in many ways and the workarounds were messy and wouldn't have been easy to support. Future versions of Web Compiler might be useful, but I came to the conclusion that it's worth the trouble to just switch to a more mature less compiling tool.

这对我有用: 禁用Web编译器 工具->扩展和更新->已安装(搜索Web编译器)->禁用

This is what worked for me: Disable Web Compiler Tools->Extensions and Updates->Installed(search for Web Compiler)->Disable

然后按照其中的许多教程之一来设置Grunt.js.我用的是Scott Hanselman的这篇文章: http://www.hanselman.com/blog/IntroducingGulpGruntBowerAndNpmSupportForVisualStudio.aspx

Then setup Grunt.js by following one of the many tutorials out there. I used this one by Scott Hanselman: http://www.hanselman.com/blog/IntroducingGulpGruntBowerAndNpmSupportForVisualStudio.aspx

这是我发现非常有用的另一本指南: https://www.orderfactory.com/articles/Bootstrap-LESS- Grunt-VS.html

Here's another guide I found very useful: https://www.orderfactory.com/articles/Bootstrap-LESS-Grunt-VS.html

由于听起来您基本上就像我在遵循这些说明之前一样,所以您有可能会遇到TypeScript编译的另一个问题,该问题默认情况下是Web编译器打开的.

Since it sounds like you were basically where I was before I followed these instructions, there's a chance you might run into another issue with TypeScript compiling, which Web Compiler turned on by default.

如果您遇到一堆与lib.core.d.ts相关的重复标识符"错误,则可能必须禁用自动打字稿编译: 右键单击Project-> Properties-> TypeScript Build->取消选中保存时编译"

If you get a bunch of "duplicate identifier" errors related to lib.core.d.ts, you may have to disable automatic typescript compiling: right-click Project->Properties->TypeScript Build->uncheck "Compile on save"

安装Web编译器并设置节点工具并分配自动化任务可能会导致ts编译器释放出来,使其可以在所有node_modules中运行,从而寻找可编译的内容.可能是一团糟.

Installing Web Compiler and setting up node tools and assigning an automated task can result in unleashing the ts compiler to run through all the node_modules, looking for things to compile. It can be a mess.

如果要让TypeScript在构建时进行编译,则需要在项目的根目录中添加tsconfig.json文件,以定义特定的文件路径.没有这个文件,编译器到处都是,而您真的不想要那个.我发现禁用它会更容易.

If you want to leave TypeScript compiling on build, you'll need to add a tsconfig.json file to the root of your project to define specific file paths. Without this file, the compiler looks everywhere and you really don't want that. I found it easier to just disable it.

有关此的更多信息: 打字稿,混淆了重复标识符";错误消息

Here's more information on that: Typescript, confusing "duplicate identifier" error message

希望这会有所帮助.

这篇关于无法使用Web Compiler 2015编译更少的嵌套文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆