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

How to integrate AntD with Webpack2 #4491

Closed
andrewvmail opened this issue Jan 5, 2017 · 4 comments
Closed

How to integrate AntD with Webpack2 #4491

andrewvmail opened this issue Jan 5, 2017 · 4 comments
Assignees

Comments

@andrewvmail
Copy link

Environment(required)

  • antd version: 2.6.0
  • OS and its version: Windows 7 & Mac OS 10.11.5
  • Browser and its version: Webpack issue

What did you do? Please provide steps to re-produce your problem.

  1. https://github.com/mxstbr/react-boilerplate
  2. Add antd

What do you expected?

A smooth process without modifying things in antd package side (datepicker module date-picker/locale/zh_CN.js:23).

I tried configuring through webpack different settings specifically dll, plugins, alias, noParse settings tried all settings from different tickets but still can't get it to work smoothly.

What happen?

npm run build:dll

ERROR in dll reactBoilerplateDeps
Module not found: Error: Can't resolve 'moment/locale' in '/Users/andrew/projects/lift/frontend'
 @ dll reactBoilerplateDeps

Nothing major but its only an eye sore seeing the error during the build process.
Thanks in advance
A

@afc163
Copy link
Member

afc163 commented Jan 6, 2017

Finally I make it work at react-boilerplate:afc163/react-boilerplate@b1366a6, and still struggling for moment locale setting.


Ok, I found a workaround for antd by just adding resolve.alias! 🎆

afc163/react-boilerplate@61ec8a1

alias: {
- moment: 'moment/moment.js',
+ moment$: 'moment/moment.js',
},

This came from https://webpack.js.org/configuration/resolve/#resolve-alias to match the import moment from 'moment' exactly and ignore locale importing statements like require('moment/locale/xx').

You can try it on https://github.com/afc163/react-boilerplate

@afc163
Copy link
Member

afc163 commented Jan 10, 2017

@andrewvmail You can look reply above.

afc163 added a commit to afc163/react-boilerplate that referenced this issue Feb 15, 2017
@ghost
Copy link

ghost commented Mar 30, 2017

Having the same issue (as the title - don't really understand what moment.js has to do with antd and webpack2). Would be great to see how antd, especially the css bit works with latest webpack. All examples I find are outdated.

@tanduong
Copy link

tanduong commented Jul 7, 2017

For anyone who landed here, this commit works: afc163/react-boilerplate@61ec8a1

Just remember to rebuild your dll, by running yarn install again if you are using react boilerplate.

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

No branches or pull requests

4 participants