You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first time trying out bitsrc and running into a problem creating a sass component. I'm creating a sass component that currently depends on the bulma node_modules package. In my sass file i am importing bulma as so,
@import '~bulma/sass/utilities/_all.sass';
The issue is that sass using the tilda as a resolver to link to packages in node_modules but bitsrc does not recognize this.
Any workarounds here?
Expected Behavior
Able to import using sass ~ alias to load in files from node_modules packages
Actual Behavior
Errors out saying ~package-name is unavailable
Steps to Reproduce the Problem
create sass files
in the sass file import a sass file from a node modules package using @import ~ syntax
Seems like the issue comes from the 'detective-sass' library.
It fails to parse the line with the 'import' statement. You can easily see it happening when adding "DEBUG=*" before the command.
Here is what I get from detective-sass:
detective-sass content: @import "~bulma/sass/utilities/_all.sass"; +0ms
detective-sass parse error: Please check validity of the block starting from line #1 +9ms
I tried working with this package solely and I get the same parse error. @uptownhr if you can post the issue in the detective-sass Github repo, it'd be great.
As to the tilda, Bit actually supports it. (See the specific code here. )
components/button
missing packages dependencies (use your package manager to make sure all package dependencies are installed):
src/components/Button.vue -> ~@
Another fix related to this issue has been done two weeks ago here: teambit/bit-javascript#100.
The current version, v14.1.3 has it all fixed.
I'll explain it as it is not trivial.
There are two main cases here.
Case 1: there is a match with resolveModules.aliases settings
For example, your scss file has import '~scss/styles.scss'; and your workspace config has resolveModules.aliases: { "~scss": "src/scss" }
Bit will use the resolveModule setting, regardless of whether it has a slash after the Tilda (~/) or not (~).
In the example above, it'll resolve the dependency to src/scss/styles.scss.
Same thing if your dependency is import '~/scss/styles.scss'; and your workspace config has resolveModules.aliases: { "~/scss": "src/scss" }, it will not try to resolve to node_modules, because you have your custom resolve settings.
Case 2: there is no match with resolveModules.aliases settings
Whether you didn't configure anything or your configuration doesn't match the current import statement.
Bit uses the Webpack Sass Loader settings here, which states that ~/ (e.g. ~/bootstrap) resolves to a local file, but ~ (e.g. ~bootstrap) resolves to the node_modules.
In their words:
webpack provides an advanced mechanism to resolve files. The sass-loader uses Sass's custom importer feature to pass all queries to the webpack resolving engine. Thus you can import your Sass modules from node_modules. Just prepend them with a ~ to tell webpack that this is not a relative import:
@import "~bootstrap/dist/css/bootstrap";
It's important to only prepend it with ~, because ~/ resolves to the home directory. webpack needs to distinguish between bootstrap and ~bootstrap because CSS and Sass files have no special syntax for importing relative files. Writing @import "file" is the same as @import "./file";
Activity
davidfirst commentedon Apr 26, 2018
Seems like the issue comes from the 'detective-sass' library.
It fails to parse the line with the 'import' statement. You can easily see it happening when adding "DEBUG=*" before the command.
Here is what I get from detective-sass:
I tried working with this package solely and I get the same parse error.
@uptownhr if you can post the issue in the detective-sass Github repo, it'd be great.
As to the
tilda, Bit actually supports it. (See the specific code here. )uptownhr commentedon Apr 27, 2018
Hmm thanks for that. Looking at https://github.com/teambit/bit-javascript/blob/master/src/dependency-builder/filing-cabinet/index.js#L51, can we add '.scss' to this list? My files are written in scss, and explains the problem :).
adding scss to support ~ (#52)
itaymendel commentedon Aug 23, 2018
closing this issue as the matter was handled in the issue david closed about a month ago
cj commentedon Sep 17, 2018
@itaymendel I just run into this exact issue using bit-bin
v13.0.4, has support for this not been merged in yet?davidfirst commentedon Sep 20, 2018
@cj , part of this issue has been fixed recently on #1215.
This part has not been merged yet.
javed74 commentedon Dec 8, 2018
@davidfirst - I am also facing same issue. Any idea when this fix will be released? (I am using v13.0.4)
mrdoinel commentedon Jan 25, 2019
I am getting the same issue when trying to import a SCSS file into my vue component.
At the end of my Button.vue
bit status
The content of my bit.json :
I am using v13.0.4.
mrdoinel commentedon Jan 25, 2019
For those who are getting the same issue, it is working if the path is relative (which is a bit annoying) :
@import '../components/style.scss';
mathieuartu commentedon Jun 13, 2019
What's the status on this? I'd like to import scss files without using the relative path...
davidfirst commentedon Jun 14, 2019
Another fix related to this issue has been done two weeks ago here: teambit/bit-javascript#100.
The current version, v14.1.3 has it all fixed.
I'll explain it as it is not trivial.
There are two main cases here.
Case 1: there is a match with
resolveModules.aliasessettingsFor example, your scss file has
import '~scss/styles.scss';and your workspace config hasresolveModules.aliases: { "~scss": "src/scss" }Bit will use the
resolveModulesetting, regardless of whether it has a slash after the Tilda (~/) or not (~).In the example above, it'll resolve the dependency to
src/scss/styles.scss.Same thing if your dependency is
import '~/scss/styles.scss';and your workspace config hasresolveModules.aliases: { "~/scss": "src/scss" }, it will not try to resolve to node_modules, because you have your custom resolve settings.Case 2: there is no match with
resolveModules.aliasessettingsWhether you didn't configure anything or your configuration doesn't match the current
importstatement.Bit uses the Webpack Sass Loader settings here, which states that
~/(e.g.~/bootstrap) resolves to a local file, but~(e.g.~bootstrap) resolves to the node_modules.In their words:
https://github.com/webpack-contrib/sass-loader