Closed
Description
use ant-design in create-react-app,err in react-app-rewire-less,details that the flowing items show.
1.package.json
2.config-override
3.npm start err
4.delete some code related to less,it works but...no style!
5.update config-override.js type:true ===> type:'css',it works for css but not for less.
how to resolve it to make my project works well ?
Activity
likun7981 commentedon Nov 27, 2017
I try it with your version, it is not wrong.
Can you provide your demo code?
zhaoyu69 commentedon Nov 27, 2017
https://github.com/zhaoyu69/antd-spa
This is my github address.
It contains serialport, so you have to config
from https://github.com/nodejs/node-gyp.
Thanks!
zhaoyu69 commentedon Nov 27, 2017
Or you can commented out some part of component.
I just want to see the less style to work.
likun7981 commentedon Nov 28, 2017
I test your demo code and add
rewire-less
with options, it is not wrong.zhaoyu69 commentedon Nov 28, 2017
I try again with another PC , also not work. can you give me some advice?
dawnmist commentedon Nov 28, 2017
I've also just tried your git repo (master). Before I could test, I made the following changes:
Having made those 3 changes to the master version of your repository, both
.
yarn start
andnpm run start
were able to run the app and show the login screenAre you working on Windows? I'm wondering whether the test for finding the file-loader config rule inside the less rewire is failing due to the difference in Windows vs Linux path separators.
likun7981 commentedon Nov 29, 2017
The path separators is use
path.sep
, This can not be a path separators question. you can clear yournpm cache
and deletepackage-lock.json
, try again install.dawnmist commentedon Nov 29, 2017
I saw that we were using
path.sep
- what I wasn't sure about was whether therequire.resolve('file-loader')
that react-scripts use returns the path in Windows or Posix format when used on a Windows system. Since the actual failure line points to the line where we try to alter the file-loader rule, it stands to reason that there is something odd causing it to be unable to find that rule on some computers. Since the example repo also had an issue where it was importing a local file with the wrong case ('ACQ1.less' instead of 'acq1.less'), it indicated that @zhaoyu69 was possibly working on an OS where filenames were not case-sensitive. Hence my question about using Windows and why I was suspicious that there might have been a mismatch between the file-loader definition from react-scripts and our searching for it using path.sep.zhaoyu69 commentedon Dec 1, 2017
I Follow your steps,try again but failed too,I'm going to redo my system then try again.
dawnmist commentedon Dec 1, 2017
@zhaoyu69 If it is still failing after redoing your system, could you please alter your config-overrides.js file to add the following 3 lines after the call to injectBabelPlugin to get some logging output then post the output:
Note: This will not fix anything, its purpose is to generate some debugging information so that we can try to see what the react-app-rewire-less plugin is being given as input. The
throw new Error
just makes sure that the script doesn't continue any further. All 3 new lines should be removed again after generating the logging text.zhaoyu69 commentedon Dec 4, 2017
I added a word : const { path } = require('path');
but throw error : TypeError: Cannot read property 'sep' of undefined
How to deal with it?
dawnmist commentedon Dec 4, 2017
Sorry - I forgot that bit.
Use
const path = require('path');
- no braces.7 remaining items