首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用内联样式加载器加载变量或混合

无法使用内联样式加载器加载变量或混合
EN

Stack Overflow用户
提问于 2016-05-25 05:47:28
回答 1查看 527关注 0票数 0

我想在inline-styles中使用twitter-bootstrap,为此,我进行了以下设置:

代码语言:javascript
复制
{
   test: /\.scss$/,
   loaders: ['raw', 'inline-style', 'autoprefixer?' + autoprefixerOptions, 'sass']
}

我已经使用npm安装了bootstrap-sassradium。我写了这段代码:

代码语言:javascript
复制
import normalize from 'radium-normalize'
import m from '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_mixins.scss'
import v from '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_variables.scss'
import sc from '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_scaffolding.scss'
import t from '../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_type.scss'
import buttons from '..//node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_buttons.scss'

我尝试将这些代码添加到radium提供的Style组件中,如下所示:

代码语言:javascript
复制
const baseRules = {...normalize, ...m, ...v, ...sc, ...type}
const App = () => (
  <div>
    <Style rules={baseRules} />
    <HelloWorld />
  </div>
)

我收到以下错误,通知我没有定义变量和混合:

代码语言:javascript
复制
 ERROR in ./~/bootstrap-sass/assets/stylesheets/bootstrap/_scaffolding.scss
Module build failed: 
  @include box-sizing(border-box);
          ^
      No mixin named box-sizing

Backtrace:
    stdin:12
      in /home/vamsi/Do/webpack-npm-plugin/node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_scaffolding.scss (line 12, column 12)
 @ ./src/index.js 21:19-107

ERROR in ./~/bootstrap-sass/assets/stylesheets/bootstrap/_type.scss
Module build failed: 
  font-family: $headings-font-family;
              ^
      Undefined variable: "$headings-font-family".
      in /home/vamsi/Do/webpack-npm-plugin/node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_type.scss (line 11, column 16)
 @ ./src/index.js 25:12-93

ERROR in ./~/bootstrap-sass/assets/stylesheets/bootstrap/_buttons.scss
Module build failed: 
  font-weight: $btn-font-weight;
              ^
      Undefined variable: "$btn-font-weight".
      in /home/vamsi/Do/webpack-npm-plugin/node_modules/bootstrap-sass/assets/stylesheets/bootstrap/_buttons.scss (line 12, column 16)
 @ ./src/index.js 29:15-100
EN

回答 1

Stack Overflow用户

发布于 2016-06-07 13:19:15

确保将bootstrap @import到需要混合的scss文件中。对于同构的样式,你永远不会知道你的入口点可能是什么,所以你不会在一个地方使用它,然后忘记它。

尝试像这样导入:

代码语言:javascript
复制
   @import "~/bootstrap-sass/assets/stylesheets/bootstrap/mixins"

~字符将告诉webpack查看modulesDirectories解析器(See more)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37424469

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档