Skip to content

webpack alias with tilde not working for imports #566

@philippkuehn

Description

@philippkuehn

With sass-loader < 7.0.0 this worked fine

// webpack config
resolve: {
	alias: {
		fonts: path.resolve(__dirname, '../src/assets/fonts'),
		settings: path.resolve(__dirname, '../src/assets/sass/settings.scss'),
	},
},
// works
@import '~settings';

// works
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 300;
  src: url('~fonts/rubik-v7-latin-300.woff2') format('woff2'),
       url('~fonts/rubik-v7-latin-300.woff') format('woff');
}

With sass-loader >= 7.0.0

// error: can't resolve '~settings'
@import '~settings';

// works
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 300;
  src: url('~fonts/rubik-v7-latin-300.woff2') format('woff2'),
       url('~fonts/rubik-v7-latin-300.woff') format('woff');
}

Is this an expected behavior or an bug?

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