2016-06-27 7 views
0

私はCSSモジュールとSass Loaderを利用しようとしていますが、動作していないようです。が、私は/static/をチェックするとき、私は唯一のbundle.jsなくstyle.scssを参照してください。webpackの設定が自分のscssファイルで動作しない:(

var webpack = require('webpack'); 
var ExtractTextPlugin = require('extract-text-webpack-plugin'); 
var path = require('path'); 

module.exports = { 
    devtool: 'source-map', 
    entry: [ 
    'webpack-hot-middleware/client', 
    'index.js' 
    ], 
    output: { 
    path: path.join(__dirname, 'dist'), 
    filename: 'bundle.js', 
    publicPath: '/static/' 
    }, 
    resolve: { 
    root: path.resolve(__dirname), 
    extensions: ['', '.js', '.jsx'] 
    }, 
    module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     loaders: [ 
      'react-hot', 
      'babel' 
     ], 
     include: path.join(__dirname, ''), 
     exclude: /node_modules/ 
     }, 
     { 
     test: /\.(png|jpg)$/, 
     loader: 'file-loader?name=img/[name].[ext]' 
     }, 
     { 
     test: /\.scss$/, 
     loader: ExtractTextPlugin.extract('style-loader', ['css-loader', 'autoprefixer-loader', 'sass-loader']) 
     } 
    ] 
    }, 
    plugins: [ 
    new webpack.optimize.OccurenceOrderPlugin(), 
    new webpack.HotModuleReplacementPlugin(), 
    new ExtractTextPlugin('/static/style.css', { 
     allChunks: true 
    }) 
    ] 
}; 

答えて

0

あなたが(それはpublicPathに基づいているため)だけでなく、ファイルパス、ファイル名を追加する必要が

... 
    module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     loaders: [ 
      'react-hot', 
      'babel' 
     ], 
     include: path.join(__dirname, ''), 
     exclude: /node_modules/ 
     }, 
     { 
     test: /\.(png|jpg)$/, 
     loader: 'file-loader?name=img/[name].[ext]' 
     }, 
     { 
     test: /\.scss$/, 
     loader: ExtractTextPlugin.extract('style-loader', 'css-loader', 'autoprefixer-loader', 'sass-loader') 
     } 
    ] 
    }, 
    plugins: [ 
    new webpack.optimize.OccurenceOrderPlugin(), 
    new webpack.HotModuleReplacementPlugin(), 
    new ExtractTextPlugin('style.css', { 
     allChunks: true 
    }) 
    ] 
}; 
+0

こんにちは。私はこれを試しましたが、まだ動作していないようです。スタイルは全く変わらない – user1354934

関連する問題