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.

CSS Compilation Issue

See original GitHub issue

Using a default Laravel installation and importing the SCSS stylesheet, Sweet Alert is unable to compile due to the following error.

import Swal from ‘sweetalert2/dist/sweetalert2.js’ import ‘sweetalert2/src/sweetalert2.scss’

warn - You have enabled the JIT engine which is currently in preview.
ERROR in ./node_modules/sweetalert2/src/sweetalert2.scss (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[7].oneOf[1].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[7].oneOf[1].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[7].oneOf[1].use[3]!./node_modules/sweetalert2/src/sweetalert2.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined function.
    ╷
517 │ $icon-zoom: math.div(strip-units($swal2-icon-size), 5);
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ╵
  node_modules\sweetalert2\src\scss\_core.scss 517:13  @import
  node_modules\sweetalert2\src\scss\_theming.scss 8:9  @import
  node_modules\sweetalert2\src\sweetalert2.scss 4:9    root stylesheet


Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
zenflowcommented, Jul 31, 2021

Ok, looks like this is happening because the math.div function used is available with the Dart Sass compiler but not with the LibSass compiler… See https://sass-lang.com/documentation/modules/math#div

Sweetalert2’s own build system uses the Dart Sass package.

We know (based on the error above) that Laravel is using sass-loader. The docs for that package say it can use either Node Sass (which uses LibSass) or Dart Sass, and I’m guessing your default Laravel installation is set up with Node Sass.

@tomshaw You could see about changing the Laravel installation to use the Dart Sass package instead of Node Sass.

1reaction
limontecommented, Sep 16, 2021

Can we just include the compiled CSS in the dist from npm?

It’s included.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix compiling problems with .css file - Stack Overflow
css file but I ran into some compilation issues. I'm not as familiar with .css so it was hard for me to fix...
Read more >
CSS Compile Error - Material Design for Bootstrap
Hello, I am trying to set the order of SCSS files in my main SCSS file. I'd like to compile in the following...
Read more >
Sass compilation error - HTML-CSS - The freeCodeCamp Forum
I try to compile my sass code to css using the command: “npm run compile_sass” but keeps getting this error message below:
Read more >
CSS compilation issue when $enable-rounded: true #1508
When $enable-rounded is set to true , CSS compilation fails: ╷ 1875 │ $carousel-indicator-active-radius: 0 100% 100% 0 / ...
Read more >
Webpack and Bulma CSS compilation Error - Laracasts
Webpack and Bulma CSS compilation Error. Hey,. Following is my package.json. Copy Code "devDependencies": { "axios": "^0.15.2", "bootstrap-sass": "^3.3.7", ...
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

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