React Toolbox查找~coacting-toolbox / lib / colors

时间:2017-01-05 16:13:50

标签: javascript css reactjs webpack-dev-server react-toolbox

我在尝试使用工具箱设置webpack时遇到了一些问题。 出于某种原因,我不知道为什么它不起作用。

我的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 任何有关最新情况的帮助都会非常感激。 谢谢!

1 个答案:

答案 0 :(得分:0)

我可以通过从导入开始删除~来解决此问题。

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

postcss-import插件似乎有same behvaior