Skip to content

Resolving import/compose css paths in node_module with version 2.0.0 #861

@mbulfair

Description

@mbulfair
  • Operating System: OS X
  • Node Version: 10.13.0
  • NPM Version: 6.4.1
  • webpack Version: 4.27.1
  • css-loader Version: 2.0.0

Expected Behavior

Actual Behavior

Importing with css compose and import to a node module. In version 1.0.1 the ~ was not needed. In 2.0.0 it is. While in my local project I can change any references to this with no issue. However in the node_module/package/file.css if it doesn't have that same ~ then webpack/css loader can't resolve the path.

Code

Below works with 1x and partially with 2x,

also in the test of css, I am excluding a series of local node_modules, internal only packages. This may be some of the issue.

{
   loader: "css-loader",
              options: {
                modules: true,
                localIdentName: "[name]__[local]-[hash:base64:5]",
                url: false,
                importLoaders: 1
              }
            },

How Do We Reproduce?

Local File:

@value color-grey from "~@localpackage/styles/color.css";

.copyright {
  color: color-grey;
  composes: type-heading from "~@localpackage/theme/styles/typography.css";
  margin: 0;
  padding: 0;
}

Node Module

.type-heading {
  color: red
  composes: type-heading2 from "@localpackage/theme/styles/typography.css";
  margin: 0;
  padding: 0;
}

Error in resolving ☝️ with local webpack build

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