Webpack alias not working for sass "composes" imports
Asked Answered
M

1

6

I have a few aliases set up in webpack like this:

  resolve: {
    alias: {
      data: path.resolve(__dirname, 'data'),
      withStyles: 'isomorphic-style-loader/lib/withStyles',
      modules: path.resolve(__dirname, 'src', 'modules'),
      components: path.resolve(__dirname, 'src', 'components'),
    },

They're working fine when doing @imports in sass files at the top of a file:

@import '~components/common/css/mixins';

.root {
  @include scale-size(padding-top, 24px, 42px);

...

However, when loading with "composes" it says it can't find the module:

.bottom-cta {
  composes: cta from '~components/common/css/button';
...

However, if using a "normal" path (../../components/common/css/button) it works.

Is this expected behaviour? How can i solve this?

Thanks in advance.

Manning answered 9/3, 2017 at 6:44 Comment(2)
try without ~Tega
Does not help unfortunately.Manning
C
0

Use https://www.npmjs.com/package/postcss-modules-resolve-from-alias

Please note that you'll need to add aliases separately to your config and you will still lose IDE support.

Commixture answered 11/10, 2018 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.