Skip to content

Possible issue with webpack path resolver after migrating to v.5.0.0 #11838

Open

Description

@Korabelnykov

Hello cra team,
We have mono repository with 4 project and components library. We use yarn worspace to symlink components dependecy to project.
Components library is built with rollup. TS and CSS are compiled into bundles. Also we are copiing scss variables to dist for reusing it in projects.
We import styles and scss variables to projects from node_modules using alias like this

import "~components/dist/style.css"
import "~components/scss/variable"

Everything works fine on 4.0.3, but after migarting to 5.0.0 looks like something wrong with path resolver in webpack.
We also have tried without ~, as it is deprecated in sass, but result is still the same.
Also we are not able to load some JSON files in typescript module from "components/dist/some.json"
We are using react-scripts with typescript, seems like exports property in package.json is still experimental for typescript.

We have already tried all of the simple solutions like re-install of the node_modules.

Could you please assist?
147358341-27922286-a338-4126-a8b0-e6b111232844
absolute_common_lib_path-not-working2
css-loader-error-with-sass-loader
path-resolver-with-relative-path-works

Activity

  1. stanlaktionov commented on Jan 4, 2022

    @stanlaktionov

    Any updates on this?

  2. haworku commented on Jan 4, 2022

    @haworku

    I'm seeing this same issue with not being able to find scss stylsheets after upgrade

    Also have tried

    • deleting and regenerating the yarn.lock and node_modules
    • changing SASS_PATH (what we used previously prior to upgrade) and trying to use REACT_APP_SASS_PATH since I was reading different things about each env variable in earlier issues on this repo. Also tried using both set to the same value
  3. bstaruk commented on Feb 3, 2022

    @bstaruk

    I was having this same issue and solved it by:

    1. Renaming SASS_PATH to REACT_APP_SASS_PATH in .env (ex: REACT_APP_SASS_PATH=./node_modules;./src)
    2. Adding full filenames to every @import, @use, etc... for example, @import 'style/variables becomes @import 'style/_variables.scss.

    After making these changes I was back in business with CRA v5 (upgrading from v4).

  4. furmandev commented on Mar 1, 2022

    @furmandev

    Experiencing this issue as well.

    Changing imports from @use 'variables' to @use 'src/styles/_variables.scss' removes the warning, but this is not ideal IMO

  5. haworku commented on Apr 4, 2022

    @haworku

    I was able to also fix my issue by using full paths as described ^

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions