Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无法使用antd-mobile #203

Closed
squallzhou opened this issue Aug 31, 2016 · 5 comments
Closed

无法使用antd-mobile #203

squallzhou opened this issue Aug 31, 2016 · 5 comments

Comments

@squallzhou
Copy link

  • antd-mobile 版本:0.8.0
  • 操作系统及其版本:macOS10.11.6
  • 浏览器及其版本:chrome 52.0

你做了什么?

引入 antd-mobile 的 Button

你期待的结果是:

像官网一样正常显示

实际上的结果:

Module not found: Error: Cannot resolve module 'antd-mobile' in /Users/zhouxiaobo/Study/reactjs/mobile-demo

可重现的在线演示

  1. 安装了antd-mobile
  2. 在项目的node_modules下有antd-mobile模块
  3. 在index.js里只要有import { Button } from 'antd-mobile'这句话,就无法编译,说找不到antd-mobile模块。
@silentcloud
Copy link
Contributor

silentcloud commented Sep 1, 2016

按照 readme 里配置插件,可以参考这里的例子 #56

@squallzhou
Copy link
Author

我按照readme里的配置去做了,我的weback.config.js :

module.exports = {
entry: './index.js',

output: {
filename: 'bundle.js',
publicPath: ''
},
module: {
loaders: [
{ test: /.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' },
{ test: /.css$/, loader: "style!css" },
{ test: /.less/,loader: 'style-loader!css-loader!less-loader'},
{ test: /.(png|jpg)$/, loader: 'url-loader?limit=8192'}
]
},
resolve: {
modulesDirectories: ['node_modules', path.join(__dirname, '../node_modules')],
extensions: ['', '.web.js', '.js', '.json'],
}
}

但是npm start后,有错误出来,说path没有定义。
image

这个path是在哪里定义的呢?

@silentcloud
Copy link
Contributor

主要是这个

webpackConfig.babel.plugins.push(['antd', {
    "style": "css",  // if true, use less
    "libraryName": "antd-mobile",
  }]);
  return webpackConfig;

@squallzhou
Copy link
Author

image
我搞好了,少了这行const path = require('path'); 看了原来的antd的脚手架项目的代码里,发现了这个

@yiminghe yiminghe closed this as completed Sep 1, 2016
@AnxioVic
Copy link

我在自己的config里面配置了教程里的方法,但是报modulesDirectories找不到。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants