2016-03-06 74 views
0

我使用的反應入門套件,我試圖從引導(通過NPM安裝)導入SCSS文件,它的抱怨評論:的WebPack CSS加載器將無法解析評論

ERROR in ./~/css-loader?sourceMap&modules&localIdentName=[name]_[local]_[hash:base64:3]!./~/postcss-loader!./~/bootstrap-sass/assets/stylesheets/_bootstrap.scss 
/Users/jamessherry/sites/business_website/node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss:7:1: Unknown word 

// Core variables and mixins 
^ 
@import "bootstrap/variables"; 

ERROR in ./~/css-loader?sourceMap&modules&localIdentName=[name]_[local]_[hash:base64:3]!./~/postcss-loader!./~/bootstrap-sass/assets/stylesheets/_bootstrap.scss 
Module build failed: TypeError: Cannot read property 'toString' of undefined 
    at new Input (/Users/jamessherry/sites/business_website/node_modules/postcss/lib/input.js:31:23) 
    at parse (/Users/jamessherry/sites/business_website/node_modules/postcss/lib/parse.js:22:17) 
    at new LazyResult (/Users/jamessherry/sites/business_website/node_modules/postcss/lib/lazy-result.js:61:24) 
    at Processor.process (/Users/jamessherry/sites/business_website/node_modules/postcss/lib/processor.js:34:16) 
    at processCss (/Users/jamessherry/sites/business_website/node_modules/css-loader/lib/processCss.js:188:11) 
    at Object.module.exports (/Users/jamessherry/sites/business_website/node_modules/css-loader/lib/loader.js:24:2) 
@ ./~/bootstrap-sass/assets/stylesheets/_bootstrap.scss 2:18-178 18:6-24:8 19:25-185 

這裏的在app.js

import emptyFunction from 'fbjs/lib/emptyFunction'; 
import './../../../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss'; 
import s from './App.scss'; 

進口然後把它通過的WebPack裝載機:

, { 
    test: /\.scss$/, 
    loaders: [ 
     'isomorphic-style-loader', 
     'css-loader?' + (DEBUG ? 'sourceMap&' : 'minimize&') + 
     'modules&localIdentName=[name]_[local]_[hash:base64:3]', 
     'postcss-loader', 
    ], 
    } 

有誰有你的想法爲什麼?

感謝

詹姆斯

+0

您是否正在使用此反應入門工具包。 https://github.com/kriasoft/react-starter-kit – Darshan

+0

@Darshan是的,我是... :) – user1775718

+0

那麼你的'scss'裝載機在哪裏? – zerkms

回答

2

您可能需要加載第三方.scss文件與sass-loader而不是postcssRSK自帶默認+ precss + postcss-scss解析器。

$ npm install sass-loader --save-dev 

的WebPack允許您配置什麼loader爲哪個文件或者通過webpack.config.js(首選)或明確的「導入」語句中使用。例如,嘗試在CSS中添加以下行:

@import '!!sass!../../node_modules/bootstrap-sass/assets/stylesheets/_bootstrap.scss';