Sage 10 upgrade - SCSS Variables and Mixins not compiling

I’m in the process of moving an old Sage 9 site to Sage 10, everything seems to be working fine, except our SCSS files don’t seem to compile properly when running with yarn dev or build. All our variables and mixins come out like so:

image

We’re getting errors such as:

Which implies to me that it’s being treated as CSS and hasn’t compiled.

Below is my bud.config.js and my package.json - any help would be appreciated!

/**
 * Compiler configuration
 *
 * @see {@link https://roots.io/docs/sage sage documentation}
 * @see {@link https://bud.js.org/guides/configure bud.js configuration guide}
 *
 * @param {import('@roots/bud').Bud} app
 */
export default async (app) => {
  /**
   * Application assets & entrypoints
   *
   * @see {@link https://bud.js.org/docs/bud.entry}
   * @see {@link https://bud.js.org/docs/bud.assets}
   */

  app
    .entry('app', ['@scripts/app', '@styles/app'])
    .assets(['images']);


  /**
   * Set public path
   *
   * @see {@link https://bud.js.org/docs/bud.setPublicPath}
   */
  app.setPublicPath('/app/themes/aitc/public/');

  /**
   * Development server settings
   *
   * @see {@link https://bud.js.org/docs/bud.setUrl}
   * @see {@link https://bud.js.org/docs/bud.setProxyUrl}
   * @see {@link https://bud.js.org/docs/bud.watch}
   */
  app
    .setUrl('http://localhost:3000')
    .setProxyUrl('http://localhost')
    .watch(['resources/views', 'resources/styles', 'app']);

};


{
  "name": "sage",
  "private": true,
  "browserslist": [
    "extends @roots/browserslist-config"
  ],
  "engines": {
    "node": ">=16.0.0"
  },
  "type": "module",
  "scripts": {
    "dev": "bud dev",
    "build": "bud build",
    "translate": "yarn translate:pot && yarn translate:update",
    "translate:pot": "wp i18n make-pot . ./resources/lang/sage.pot --include=\"app,resources\"",
    "translate:update": "wp i18n update-po ./resources/lang/sage.pot ./resources/lang/*.po",
    "translate:compile": "yarn translate:mo && yarn translate:js",
    "translate:js": "wp i18n make-json ./resources/lang --pretty-print",
    "translate:mo": "wp i18n make-mo ./resources/lang ./resources/lang",
    "lint": "yarn lint:js && yarn lint:css",
    "lint:js": "eslint resources/scripts",
    "lint:css": "stylelint \"resources/**/*.{css,scss,vue}\"",
    "test": "yarn lint"
  },
  "devDependencies": {
    "@popperjs/core": "^2.11.7",
    "@roots/bud": "^6.12.3",
    "@roots/bud-eslint": "^6.12.3",
    "@roots/bud-postcss": "^6.12.3",
    "@roots/bud-prettier": "^6.12.3",
    "@roots/bud-sass": "^6.12.3",
    "@roots/bud-stylelint": "^6.12.3",
    "@roots/eslint-config": "^6.12.3",
    "@roots/sage": "^6.12.3"
  },
  "dependencies": {
    "custom-event-polyfill": "^1.0.7",
    "element-closest": "^3.0.2",
    "jquery": "^3.3.1",
    "litepicker": "^2.0.11",
    "polyfill-nodelist-foreach": "^1.1.2"
  }
}

1 Like

For a similar issue I prepared a sample repository for Sage 10 with SCSS (SASS):

The versions are slightly behind, but it should be still the same steps (you can see those in the commits).

Have you made these adjustments to your own theme?

2 Likes

In case it’s useful to mention, you may also want/need to add a .stylelintrc file.

What would be a good default one for SCSS in Sage? I would want to add one to the SCSS sample repository.

Cool. I was also wondering about that. With Bootstrap 5, I’m using this. Seems like when not writing code from scratch, it’s nice to start with a large set of filters and refine, rather than playing wack-a-mole until your code compiles.

1 Like

Thank for your input :slight_smile:

I have done all the steps above, except I’m not including bud-tailwindcss.

I am getting the following on install

yarn install v1.22.18
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning "@roots/bud > @roots/bud-support > type-fest@3.10.0" has unmet peer dependency "typescript@>=4.7.0".
warning "@roots/bud-sass > postcss-scss@4.0.6" has unmet peer dependency "postcss@^8.4.19".
warning "@roots/bud-sass > sass-loader@13.2.2" has unmet peer dependency "webpack@^5.0.0".
warning "@roots/bud-sass > stylelint-config-recommended-scss@9.0.1" has unmet peer dependency "stylelint@^15.0.0".
warning "@roots/bud-sass > stylelint-scss@4.7.0" has unmet peer dependency "stylelint@^14.5.1 || ^15.0.0".
warning "@roots/bud-sass > stylelint-config-recommended-scss > stylelint-config-recommended@10.0.1" has unmet peer dependency "stylelint@^15.0.0".
warning "@roots/bud-stylelint > stylelint-webpack-plugin@4.1.1" has unmet peer dependency "webpack@^5.0.0".
warning "@roots/eslint-config > @babel/eslint-parser@7.21.8" has unmet peer dependency "@babel/core@>=7.11.0".
warning "@roots/eslint-config > @babel/eslint-parser@7.21.8" has unmet peer dependency "eslint@^7.5.0 || ^8.0.0".
warning "@roots/eslint-config > @typescript-eslint/eslint-plugin@5.59.5" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
warning "@roots/eslint-config > @typescript-eslint/parser@5.59.5" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
warning "@roots/eslint-config > eslint-config-prettier@8.8.0" has unmet peer dependency "eslint@>=7.0.0".
warning "@roots/eslint-config > eslint-plugin-import@2.27.5" has unmet peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
warning "@roots/eslint-config > eslint-plugin-jsx-a11y@6.7.1" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
warning "@roots/eslint-config > eslint-plugin-prettier@4.2.1" has unmet peer dependency "eslint@>=7.28.0".
warning "@roots/eslint-config > eslint-plugin-prettier@4.2.1" has unmet peer dependency "prettier@>=2.0.0".
warning "@roots/eslint-config > eslint-plugin-react@7.32.2" has unmet peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
warning "@roots/eslint-config > eslint-plugin-react-hooks@4.6.0" has unmet peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0".
warning "@roots/eslint-config > @typescript-eslint/eslint-plugin > @typescript-eslint/type-utils@5.59.5" has unmet peer dependency "eslint@*".
warning "@roots/eslint-config > @typescript-eslint/eslint-plugin > @typescript-eslint/utils@5.59.5" has unmet peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
warning "@roots/eslint-config > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react > @babel/plugin-transform-react-display-name@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react > @babel/plugin-transform-react-jsx@7.21.5" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react > @babel/plugin-transform-react-jsx-development@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react > @babel/plugin-transform-react-pure-annotations@7.18.6" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "@roots/sage > @roots/bud-preset-wordpress > @roots/bud-react > @babel/preset-react > @babel/plugin-transform-react-jsx > @babel/plugin-syntax-jsx@7.21.4" has unmet peer dependency "@babel/core@^7.0.0-0".
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
[5/5] Building fresh packages...
success Saved lockfile.
Done in 7.88s.

Not sure why though - maybe it’s related.

When you clone, npm install and run the build of this sample repository on your workstation, does it work? And would you get those warnings during npm install as well?

1 Like

Thank you for your help, I set up the repo and it does work, have the same errors as well. It helped me narrow it down to the fact that the imports are what causes the issues.

My code imports everything in app.scss e.g.

@import url("utilities/_normalize.scss");

I had tried different ways of importing:

@import "utilities/normalize";

But stylelint had moaned about import-notation. I decided to change/turn off import-notation linting and the different way of importing worked. So thank you for your help debugging the issue!

1 Like