DocSpring / craco-antd

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

Update Craco less to fix production build problem #28

Closed pybuche closed 4 years ago

pybuche commented 4 years ago

Hi !

It looks like there is a problem with the craco-less dependency. I updated the version to the latest one, I guess this would help solve my problem.

Below the error log I encountered. Looks like it happens a few other times after reading the issues. Hope this PR will solve it 🤞 Thanks !

/app/node_modules/@craco/craco/lib/plugin-utils.js:29
    throw new Error(
    ^

Error: Found an unhandled loader in the production webpack config: /app/node_modules/style-loader/index.js

This error probably occurred because you updated react-scripts or craco. Please try updating craco-less to the latest version:

   $ yarn upgrade craco-less

Or:

   $ npm update craco-less

If that doesn't work, craco-less needs to be fixed to support the latest version.
Please check to see if there's already an issue in the FormAPI/craco-less repo:

   * https://github.com/FormAPI/craco-less/issues?q=is%3Aissue+webpack+unknown+rule

If not, please open an issue and we'll take a look. (Or you can send a PR!)

You might also want to look for related issues in the craco and create-react-app repos:

   * https://github.com/sharegate/craco/issues?q=is%3Aissue+webpack+unknown+rule
   * https://github.com/facebook/create-react-app/issues?q=is%3Aissue+webpack+unknown+rule

    at throwUnexpectedConfigError (/app/node_modules/@craco/craco/lib/plugin-utils.js:29:11)
    at throwError (/app/node_modules/craco-less/lib/craco-less.js:14:5)
    at /app/node_modules/craco-less/lib/craco-less.js:119:7
    at Array.forEach (<anonymous>)
    at Object.overrideWebpackConfig (/app/node_modules/craco-less/lib/craco-less.js:51:11)
    at Object.overrideWebpackConfig (/app/node_modules/craco-antd/lib/craco-antd.js:63:26)
    at overrideWebpack (/app/node_modules/@craco/craco/lib/features/plugins.js:42:40)
    at /app/node_modules/@craco/craco/lib/features/plugins.js:64:29
    at Array.forEach (<anonymous>)
    at applyWebpackConfigPlugins (/app/node_modules/@craco/craco/lib/features/plugins.js:63:29)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! staycation-admin@1.0.0 start: `craco start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the staycation-admin@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /app/.npm/_logs/2020-04-30T08_11_08_192Z-debug.log
pybuche commented 4 years ago

Hi,

I pushed a deep further my investigation and it looks like it fixes the problem ! I'm not exactly sure where the problem lies, but it seems that either craco-less or react-scripts new versions uses an additionnal loader in the webpack config, thus the error.

Updating them seems to be OK. Could anyone else test it to validate this fix?

Thx!

pybuche commented 4 years ago

Weird behavior of the yarn audit command 🤔

ndbroadbent commented 4 years ago

Hello, thanks a lot for the PR! It looks like yarn audit is showing some security vulnerabilities. I was wondering if I could please ask for your help with updating some of these packages? (If it can't be fixed with an update, then it might also be ok to comment out the yarn audit line temporarily.)

ndbroadbent commented 4 years ago

Hello, thanks very much! I've rebased and merged in your changes

ndbroadbent commented 4 years ago

Changes have been pushed to craco-antd version 1.15.0

pybuche commented 4 years ago

Hi! Sorry I took a few days to answer. Good news, thanks for the update! In the meantime, I had to improvise and do it by myself to make the antd overrides work. I'll update craco-antd as soon as I can.

If you need anything else, please tell me