我正在写一个网络应用程序,并想挂钩一些css @media查询引导变量。所以我下载了bootstrap,并决定让我的兄弟编译它,当它编译我自己的less文件时。
我的Gruntfile的相关部分如下所示
less: {
dev: {
options:{
paths: ['app/stylesheets', 'app/stylesheets/bootstrap'], // All the `less` files from bootstrap are placed in 'app/stylesheets/bootstrap' //
},
files: {
'build/pretty/style.css':'app/stylesheets/**/*.less'
}
}
}但是,当我运行grunt grunt less:dev时,它会失败并输出
Running "less:dev" (less) task
>> NameError: variable @alert-padding is undefined in app/stylesheets/bootstrap/alerts.less on line 10, column 12:
>> 9 .alert {
>> 10 padding: @alert-padding;
>> 11 margin-bottom: @line-height-computed;
Warning: Error compiling app/stylesheets/bootstrap/alerts.less Use --force to continue.
Aborted due to warnings. 我试过所有我能想到的方法,
发布于 2014-02-12 20:36:30
这是因为您正在尝试编译app/stylesheets目录中的每个.less文件,然后将它们连接到build/pretty/style.css中。这就是任务的工作方式。
这样的事情你可能会有更好的运气:
// app/stylesheets/style.less
@import "bootstrap/bootstrap.less";
// Now you'll have every bootstrap mixin, variable, class, etc available然后,在您的任务中:
less: {
dev: {
files: {
'build/pretty/style.css': 'app/stylesheets/style.less'
}
}
}如果您只需要变量和mixins,则可以使用@import (reference) "bootstrap/bootstrap.less";。这样就不会输出任何Bootstrap样式。
https://stackoverflow.com/questions/21672586
复制相似问题