Exporting Sass in NPM module

Viewed 467

I am trying to build an NPM module that will allow an SCSS file to be exported and used across a number of applications.

The SCSS file imports another SCSS in another seperate node module.

My package structure is:

package-name
|--src
|  |- overwrite.scss
|  
|--package.json
|
|--webpack.config.js
|
|--node_modules

The issue I am facing is that currently I have the paths hardcoded for the import value. For example

$background-color: red;
@import '../node_module/fake_name/dist/core.scss'

I have a dependency in package.json file to ensure that fake_name module will always be in the node_modules folder of any project that will use my npm package.

What I am trying to achieve is set it that the path of @import will always look in the node_modules folder in the root of whatever project it is installed in. I have tired using ~ but I keep getting 'Error: File to import not found or unreadable'

Any help is appreciated.

0 Answers
Related