2016-05-24 6 views
0

mit Ich mag würde twitter-bootstrap mit inline-styles, verwenden, um so zu tun, ich habe ein Setup:Kann nicht Variablen oder Mixins laden Inline-style-loader

{ 
    test: /\.scss$/, 
    loaders: ['raw', 'inline-style', 'autoprefixer?' + autoprefixerOptions, 'sass'] 
} 

habe ich installiert bootstrap-sass und radium npm verwenden. Ich schrieb diesen Code:

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' 

ich diese an die Style Komponente von radium wie dies vorgesehen ist hinzuzufügen versuchen:

const baseRules = {...normalize, ...m, ...v, ...sc, ...type} 
const App =() => (
    <div> 
    <Style rules={baseRules} /> 
    <HelloWorld /> 
    </div> 
) 

ich diese Fehler mich darüber informiert, dass Variablen und Mixins wurden nicht definiert:

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 

Antwort

0

Vergewissern Sie sich, @import bootstrap in die scss-Datei, wo Sie die Mixins benötigen. Bei isomorphen Stilen wissen Sie nie, was Sie für einen Einstiegspunkt haben, also ist es nicht so, dass Sie es an einem Ort verwenden und es vergessen.

versuchen, wie diese importieren:

@import "~/bootstrap-sass/assets/stylesheets/bootstrap/mixins" 

~ Charakter wird webpack sagen in modulesDirectories Resolvern suchen (See more)

+0

Der Inline-Style-Loader ist die falsche Sache zu verwenden, wandelt sie die Stile für die Verwendung mit dom-Elemente müsste ich dann in Javascript-Objekte konvertieren. Ich würde gerne verstehen, wie ich von etwas wie Twitter Bootstrap weniger/sass nehmen und es für die Verwendung mit Radium kompilieren kann. Der Radium-Lader wirft einen Fehler für mich auf. – vamsiampolu

Verwandte Themen