I have a scss folder outside of /src folder in my project structure this is why react angry with bu
Failed to compile.
./src/index.js
Module not found: You attempted to import ../scss/style.scss which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to
it from project's node_modules/.
here is my index.js file:
import '../scss/style.scss'
ReactDOM.render(
<HashRouter>
<Switch>
<Route path="/" name="Home Page" component={Full}/>
</Switch>
</HashRouter>,
document.getElementById('root'));
registerServiceWorker();
and this is the content of style.scss file:
// Override Boostrap variables
@import "bootstrap-variables";
// Import Bootstrap source files
@import "node_modules/bootstrap/scss/bootstrap";
// Override core variables
@import "core-variables";
// Import core styles
@import "core/core";
// Custom styles
@import "custom";
I searched a lot and understood its not allowed to import it outside of /src directory.. how can I "add a symlink" as react suggest me to do or how can I fix it other way?
EDITED: if i move scss into /src folder:
./src/scss/style.scss
Module build failed:
undefined
^
File to import not found or unreadable: bootstrap.
Parent style sheet: stdin
in D:\Repositories\facereco\src\scss\style.scss (line 14, column 1)
It's as easy as typing npm link from the root directory where your module is located(i.e where your package. json is). This will create a symlink between the global directory where your node_modules is located and the local directory where you ran this command.
Symlink a package folder during development. For development, a package can be linked into another project. This is often useful to test out new features or when trying to debug an issue in a package that manifests itself in another project.
If you want to do a symlink check the npm documentation. Here is about it https://docs.npmjs.com/cli/link
In short
cd ../scss
npm link
npm link <your_package>
And you've got it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With