Skip to content

node-sass-chokidar does not work with @import "~@name/theme/scss_file" #110

Description

@lebaphi
  • My project is a monorepo that has structure:
   name
   -node_modules
      -@name/theme
      -@name/client
   -packages
     -client
        -node_modules
        -src
          -style.module.scss
     -theme
       -node_modules
       -src
          -_variables.scss
  • I have a _variables.scss in themes package.

  • I import this file in the client package > style.module.scss

@import "~@name/themes/src/variables";

.class-a{
   property: $var
}

  • I add the watch:
    "watch:style": "node-sass-chokidar --include-path ../../node_modules ./src -o ./build --watch --recursive --ext scss", when I change style.module.scss, it shows an erorr:
{
  "status": 1,
  "file": ".../name/packages/client/src/styles.module.scss",
  "line": 1,
  "column": 1,
  "message": "File to import not found or unreadable: ~@name/theme/src/variables",
  "formatted": "Error: File to import not found or unreadable: ~@name/theme/src/variables.\n ........"
}

remove the ~ will make the watch runs success but it makes the build failed because the import in style.module.scss does not find the @name/themes in current node_modules, it should find in the root node_modules by adding ~

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions