2017-01-03 102 views
0

我採取的WebPack配置從這裏開始:的WebPack被重命名我的SCSS類

https://github.com/erikras/react-redux-universal-hot-example 
  1. 對於生產版本,我所做的修改建議,現在 裝載機少,SCSS和css的樣子這

     { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader')}, 
         { test: /\.less$/, loader: 'style!css?importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!less?outputStyle=expanded&sourceMap' }, 
         { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=2&sourceMap!autoprefixer?browsers=last 2 version!sass?outputStyle=expanded&sourceMap=true&sourceMapContents=true') } 
    
  2. 我使用要求即

    加載樣式表需要(「../ pathToSCSSSTylSheet」)

CSS被加載得很好,但SCSS類是通過的WebPack等階級是不會得到應用產生的最終樣式表重命名。如何停止重命名這些scss類?

我已經採取&localIdentName=[local]___[hash:base64:5]並試圖保持它太,但類改名反正

回答

0

刪除modules選項,這使CSS模塊。

有關更多詳細信息,請參閱https://github.com/webpack/css-loader#user-content-css-modules

如果你不想刪除modules選項,您可以像使用this

import styles from './app.scss'; 
export default class InfoBar extends Component{ 
    render(){ 
    const styles = require('./InfoBar.scss'); 
    return (
     <span className={styles.time}>10:00</span> 
    ); 
} 
} 
1

可以導入樣式這樣

:global { 
    @import 'scss_path'; 
} 

它將導入樣式的全局樣式,所以你會得到scss類而不被重命名。