首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应图标没有加载webpack

反应图标没有加载webpack
EN

Stack Overflow用户
提问于 2016-07-08 15:38:46
回答 1查看 3.7K关注 0票数 3

我正在尝试在我的项目https://github.com/gorangajic/react-icons中使用react图标。

我的webpack档案是这样的:

代码语言:javascript
复制
import webpack from 'webpack';
import path from 'path';

const GLOBALS = {
  'process.env.NODE_ENV': JSON.stringify('development'),
  __DEV__: true
};

export default {
  debug: true,
  devtool: 'cheap-module-eval-source-map', // more info:https://webpack.github.io/docs/build-performance.html#sourcemaps and https://webpack.github.io/docs/configuration.html#devtool
  noInfo: true, // set to false to see a list of every file being bundled.
  entry: [
    'webpack-hot-middleware/client?reload=true',
    './src/index'
  ],
  target: 'web', // necessary per https://webpack.github.io/docs/testing.html#compile-and-test
  output: {
    path: `${__dirname}/dist`, // Note: Physical files are only output by the production build task `npm run build`.
    publicPath: 'http://localhost:3000/', // Use absolute paths to avoid the way that URLs are resolved by Chrome when they're parsed from a dynamically loaded CSS blob. Note: Only necessary in Dev.
    filename: 'bundle.js'
  },
  plugins: [
    new webpack.DefinePlugin(GLOBALS), // Tells React to build in prod mode. https://facebook.github.io/react/downloads.htmlnew webpack.HotModuleReplacementPlugin());
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  module: {
    loaders: [
      {test: /\.js$/, include: path.join(__dirname, 'src'), loaders: ['babel']},
      {test: /\.eot(\?v=\d+.\d+.\d+)?$/, loader: 'file'},
      {test: /\.(woff|woff2)$/, loader: 'file-loader?prefix=font/&limit=5000'},
      {test: /\.ttf(\?v=\d+.\d+.\d+)?$/, loader: 'file-loader?limit=10000&mimetype=application/octet-stream'},
      {test: /\.svg(\?v=\d+.\d+.\d+)?$/, loader: 'file-loader?limit=10000&mimetype=image/svg+xml'},
      {test: /\.(jpe?g|png|gif)$/i, loaders: ['file']},
      {test: /\.ico$/, loader: 'file-loader?name=[name].[ext]'},
      {test: /(\.css|\.scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']}
    ]
  }
};

它有一个svg加载程序,所以不应该有问题,但是,我得到了以下错误ERROR in ./~/react-icons/ti/thumbs-down.js Module parse failed: /Users/Projects/react-slingshot/node_modules/react-icons/ti/thumbs-down.js Unexpected token (8:12) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected token (8:12)

不知道我遗漏了什么才能在我的项目中加载这些

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-08 16:28:22

react-icons/ti/thumbs-down.js包含未转移的ES6+JSX源。

您需要从react-icons/lib/ti/thumbs-down.js导入以获得ES5版本,因为您只在自己的src/目录上使用Babel。

README使用部分中提到了这一点。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38270582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档