Inconsistent "Relative imports outside of src/" restriction ?
See original GitHub issueIs this a bug report?
Maybe not
Which terms did you search for in User Guide?
This is related to my previous answer : https://github.com/facebook/create-react-app/issues/1333#issuecomment-428200810
Steps to Reproduce
I have a projet which imports an other “private” package. I am using sass in both packages. The private package is passed to babel only (not node-sass).
I have something like the following in the private module :
// src/component/module.js
import '../styles/module.scss';
// src/styles/module.scss
.module {
background: url('../images/module.jpg');
}
Then in the main project, if i do this :
// src/index.js
import '@my/module/dist/component/module.js';
everything works fine, but if i do “the same thing” from my sass file :
// src/main.scss
@import '@my/module/dist/styles/module.scss';
i obtain the following error :
Module not found: You attempted to import ../images/module.jpg which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
Expected Behavior
Both import should fail or success ?
To be able to split my project, i would like to be able to import other packages components and sass files.
Actual Behavior
Importing from sass from sass fails but importing sass from js works.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:30
- Comments:18 (6 by maintainers)
Top Results From Across the Web
ReactJS import component outside src/ directory
Relative imports outside of src / are not supported. You can either move it inside src/, or add a symlink to it from...
Read more >The Create-React-App Imports Restriction Outside Of Src ...
Relative imports outside of src are not supported. You can either move it inside src , or add a symlink to it from...
Read more >Relative imports don't seem to work with create-react-app
I use a bootstrapped setup from create-react-app, and it seems that relative imports for images out of the "src" folder don't seem to...
Read more >simple dapp with React "issues with solidity"
Module not found: You attempted to import ../build/contracts/SimpleStorage.json which falls outside of the project src/ directory. Relative ...
Read more >Go Modules Reference - The Go Programming Language
Canonical versions are required outside the main module, and the go ... be found in the directory $GOPATH/src/example.com/repo/sub and would be imported as ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aimadghssisse files outside
src/
are not compiled by Babel. Better keep them insrc/
folderOk finally the issue is different.
The problem is :
Both pass through webpack so the behaviour should be the same ?