question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support tilde ~ in Sass Transformer

See original GitHub issue

🙋 feature request

Support the @import '~path/to/styles.scss' syntax.

🤔 Expected Behavior

It should resolved from node_modules, it was working this way in Parcel v1.

😯 Current Behavior

Error: The @import path "~path/to/styles" is using webpack specific syntax, which isn't supported by Parcel.

To @import files from node_modules, use "path/to/styles"

The error message is actually incorrect. The tilde syntax is not only from Webpack, VScode also supports it: here’s the demo:

IGMC5dbA4i

💁 Possible Solution

Add the tilde ~ support.

🔦 Context

https://github.com/sweetalert2/sweetalert2-parcel-demo/blob/master/styles.scss

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
limontecommented, Oct 25, 2020

Thank you for the prompt response @DeMoorJasper!

This is custom syntax though.

Agree, but it’s widely used, e.g. in packages like https://github.com/sweetalert2/sweetalert2-themes where we

// 1. import default variables from the npm peer dependency
// https://github.com/sweetalert2/sweetalert2/blob/master/src/variables.scss
@import '~sweetalert2/src/variables';

// 2. allow users to override default values
$swal2-background: black;

// 3. import the actual styles which use variables from above, also from the npm peer dependency
@import '~sweetalert2/src/sweetalert2';

Without ~ those files wouldn’t be resolved properly, so ~ is actually the only one way AFAIK for this approach and IMO should be supported by Parcel v2.

2reactions
noushad-ppcommented, Nov 26, 2020

I also have the same problem as the underlying library uses the ~ format and thus even though I resolve the file import to absolute path, the file imported has the same issue and parcel compilation is failing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tilde-sass - npm
A SASS compiler with tilde (~) support for resolving node_modules path and supports new sass' syntax.. Latest version: 1.1.0, ...
Read more >
Parcel + SASS: Import from node_modules without tilde ...
it finds the stylesheet to import, but the referenced stylesheet mdc-text-field, that is inside the nodes_modules, tries to load other ...
Read more >
@parcel/transformer-sass | Yarn - Package Manager
Add . · New faster resolver supporting absolute and tilde paths, and aliases Details · Content hash output file names in production Details...
Read more >
fast-sass-loader - npm Package Health Analysis - Snyk
Learn more about fast-sass-loader: package health score, popularity, security, maintenance, versions and more. ... node-sass-tilde-importer.
Read more >
Dependency resolution - Parcel
In addition to the standard dependency specifiers supported across many tools, ... Tilde specifiers start with ~ , and resolve relative to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found