2017-01-05 27 views
2

我試圖用工具箱設置webpack時遇到了一些問題。 由於某種原因,我不知道爲什麼它不工作。React Toolbox查找〜react-toolbox/lib /色彩

我的WebPack文件看起來像:

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

module.exports = { 
    context: __dirname, 
    devtool: 'inline-source-map', 
    entry: { 
    factigisVE: './static/js/bundles/factigisVE.js', 
    vendor: [ 
     'webpack-hot-middleware/client' 
    ] 
    }, 
    output: { 
    path: path.join(path.join(__dirname, 'dist'), 'js'), 
    filename: '[name].js', 
    libraryTarget: "amd", 
    publicPath: '/' 
    }, 
    resolve: { 
    extensions: ['', '.scss', '.css', '.js', '.json','.webpack.js', '.web.js', '.js', '.jsx'], 
    modulesDirectories: [ 
     'node_modules', 
     path.resolve(__dirname, './node_modules') 
    ] 
    }, 
    module: { 
    loaders: [ 
     { 
     test: /(\.js|\.jsx)$/, 
     exclude: /(node_modules)/, 
     loader: 'babel', 
     query: { presets: ['es2015', 'stage-0', 'react','stage-2'] } 
     }, { 
     test: /(\.scss|\.css)$/, 
     loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass') 
     } 
    ] 
    }, 
    externals: [ 
     function(context, request, callback) { 
      if (/^dojo/.test(request) || 
       /^dojox/.test(request) || 
       /^dijit/.test(request) || 
       /^esri/.test(request) 
     ) { 
       return callback(null, "amd " + request); 
      } 
      callback(); 
     } 
    ], 
    devServer: { 
    inline: true, 
    port: 443, 
    host: "127.0.0.1", 
    historyApiFallback: true 
    }, 
    devtool: 'source-map', 
    postcss: [autoprefixer], 
    sassLoader: { 
    data: '@import "css/index.scss";', 
    includePaths: [path.resolve(__dirname, './static')] 
    }, 
    plugins: [ 
    new ExtractTextPlugin('../css/style.css', { allChunks: true }), 
    new webpack.optimize.OccurenceOrderPlugin(), 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.NoErrorsPlugin(), 
    new webpack.DefinePlugin({ 
     'process.env.NODE_ENV': JSON.stringify('production') 
    }) 
    ] 
}; 

然後我index.scss樣子:

@import "~react-toolbox/lib/colors"; 



$color-primary: $palette-blue-500; 
$color-primary-dark: $palette-blue-700; 

,即時通訊遇到的錯誤是:

Error: File to import not found or unreadable: ~react-toolbox/lib/colors 
parent style sheet: I:/proyect/ve/static/css/index.scss on line 1 of static/css/index.scss 

> @import "~react-toolbox/lib/colors"; 

而且我的目錄看起來像:my directory 對發生什麼事情的任何幫助將真正appr eciate。 謝謝!

回答

0

我能夠通過從導入開始刪除~來解決此問題。

@import "react-toolbox/lib/colors"; 

postcss-import插件似乎有same behvaior