michael-hack / bulma-calendar

Bulma's extension to display a calendar
MIT License
286 stars 165 forks source link

Unable to import SASS in a non-webpack project #303

Closed cdimitroulas closed 1 year ago

cdimitroulas commented 2 years ago

Your issue may already be reported! Please search on the issue track before creating one.

Bug Report

Environment

Current Behavior Importing the SCSS styles in my Rails project which does not use webpack (uses sass npm plugin) fails with an error due to the use of the ~ in imports.

My import code (bulma SCSS is imported before this line):

@import "bulma-calendar/src/sass";

The error:

Error: Can't find stylesheet to import.
  ╷
1 │ @import "~bulma/sass/utilities/functions.sass"
  │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  ╵
  bulma-calendar/src/index.sass 1:9            @import
  app/assets/stylesheets/application.scss 4:9  root stylesheet

Input Code

@import "bulma-calendar/src/sass";

Possible Solution Don't use deprecated tilde import syntax (note that this syntax is already deprecated in webpack)

Additional context/Screenshots N/A

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via codepen or similar. I think it should be easily reproducible by creating a simple SCSS file which imports bulma + bulma-calendar SCSS and then try to compile it using the scss npm module with a command like:

sass ./application.scss:./application.css --load-path=node_modules
KipK commented 1 year ago

same problem with Svelte/Vite here

knoxjeffrey commented 1 year ago

If using Vite you can handle this in the meantime with

resolve: {
  alias: {
    "~bulma": "bulma",
  },
}
Sol-Cryss commented 1 year ago

I had the same issue. I'm making a non-webpack WordPress theme using node-sass as a compiler to string some commands together (copying files after compiling, etc). In Visual Studio Code, there's an extension for Live SASS watching/compiling. I found out it uses a form of webpack so it works whenever I save and it auto-compiles... But if I build using node-sass to compile the CSS, it would give the same error as OP.

I found a solution, it's fairly simple: https://stackoverflow.com/questions/37106230/node-sass-does-not-understand-tilde#answer-57756936

Basically, install another node library, that will handle as node-sass' importer. npm install node-sass-tilde-importer --save-dev

Then set up the package.json script, or use the command line: node-sass --watch in_style.scss --importer=node_modules/node-sass-tilde-importer out_style.css

It's definitely a band-aid...

michael-hack commented 1 year ago

Should be fixed with pull request #316. Please reopen if not.