DocSpring / craco-antd

A craco plugin to use Ant Design with create-react-app
MIT License
234 stars 49 forks source link

patch: Updated tests with new code #22

Closed alexandrtovmach closed 4 years ago

ndbroadbent commented 4 years ago

Hi @alexandrtovmach, thanks for the PR! I also saw that the JS rules have changed, but I'm worried because it looks like the antd config is actually missing now, so the plugin will no longer work.

Even though the tests are passing now, the code doesn't seem to be correct because these lines are missing from the webpack configuration:

  expect(jsRule.options.plugins[0]).toEqual([
    "import",
    { libraryName: "antd", libraryDirectory: "es", style: true }
  ]);
ndbroadbent commented 4 years ago

Basically we need to figure out how to fix the webpack config so that the babel import plugin will still import everything for the antd library. I've been struggling with this for a while but haven't been able to figure it out.

The updated test is incorrect, because it is checking for:

loaderMap: {
      svg: {
        ReactComponent: "@svgr/webpack?-svgo,+titleProp,+ref![path]"
      }
    }

But this is not the expected behavior, since the rule is meant to look for our antd config.

alexandrtovmach commented 4 years ago

@ndbroadbent Okay, I see... Maybe someone with more experience in webpack can help with that

ndbroadbent commented 4 years ago

Hi @alexandrtovmach, fortunately @Vovan-VE figured out how to fix the tests in PR #23, using the new mergeWebpackConfig function. But thanks for your help!

alexandrtovmach commented 4 years ago

@ndbroadbent sure, that's great