Attempting to configure the SCSS compiler in Broccoli.js and Ember-CLI

I've been struggling to integrate Foundation into my Ember-CLI app using broccoli-scss for compiling all the SCSS files. Despite following the structure from the broccoli sample app, I just can't seem to get it working.

My approach involves having Foundation installed in my bower components and here's what I have attempted so far:

// Brocfile.js
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var pickFiles = require('broccoli-static-compiler')
var compileSass = require('broccoli-sass');

var app = new EmberApp();

var styles = 'styles'
styles = pickFiles(styles, {
  srcDir: './bower_components/foundation/scss',
  destDir: './app/styles'
});

var appsScss = compileSass([styles], './app/styles/app.scss', './app/styles/app.css');

module.exports = app.toTree();

Additionally, here is a snippet of my app/styles/app.scss file:

// app/styles/app.scss
@import "../../bower_components/foundation/scss/normalize";
@import "../../bower_components/foundation/scss/foundation.scss";

However, upon inspecting the browser, I noticed that only around 800 lines of CSS were being compiled, whereas the standard foundation.css file contains about 4.4k lines. It's clear that something is amiss with my configuration.

If anyone has any insights or solutions to offer, I'd greatly appreciate it. Thank you.

Answer №1

Here's an example to illustrate the process:

var tree = pickFiles("app/styles", {
  srcDir: '/',
  destDir: 'mui'
});
var muiTree = pickFiles("material-ui/src/less", {
  srcDir: '/',
  destDir: 'material-ui'
});
return compileLess(mergeTrees([tree, muiTree]), 'mui/app.less', 'assets/app.css')

In this code snippet, the first `pickFiles` call creates a tree for all the app styles. The second call creates a tree for the library styles (in this case, foundation). Make sure the destination directory matches the style library name (e.g., material-ui) for correct imports in your less/sass file:

@import "material-ui/scaffolding.less";
@import "material-ui/components.less";

Notice that global paths are not used for referencing material-ui files; instead, they are based on the previously assigned `destDir` name.

The `compileLess` function (similar to `compileSass` in your scenario) requires the full tree of less/sass dependencies as the first parameter, the main stylesheet as the second parameter, and the output file as the third parameter.

When less/sass needs to check for dependencies via import statements, it looks within the tree passed as the first parameter.

I hope this explanation clears things up for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Do I need to provide my email and password while using the Firebase signInWithGoogle()?

After attaching the signInWithGoogle() method to a button within the form, instead of opening a popup window as expected, it prompts me to fill in the email and password fields. Below is the configuration file: import firebase from 'firebase/app' ...

Error: IE does not recognize the 'endsWith' property or method in React Objects

I was using react-scripts version 5.0.1 in package.json and everything was working fine in IE. But after updating to 5.0.1, I started encountering an error that says: object doesn't support property or method 'endsWith' This has been giv ...

Exploring the linewidth feature in Three.js when working with LineSegmentsGeometry and LineSegments2

My goal is to create lines wider than one pixel using the LineMaterial and LineSegments2 classes from the threejs examples library. To achieve this, I've been following the guidelines provided in the response to a similar inquiry found here: Three.js ...

Is there a way to transform a complex nested class object into a simple object without losing its methods

Is there a way to convert a deeply nested class object into a plain Object type while still retaining methods like getters and setters? class A { id = ""; data = { sync: {} }; } class SyncService { syncResultServiceA = { ...

Running globally installed node modules on Windows 7 is not supported

Note: Despite scouring various posts on this issue, I have not found a solution that works for me. That's why I am reaching out here. Problem: I am facing an issue while trying to set up the http-server package on my Windows 7 system using the comman ...

Having trouble with React state not updating accurately. The increment and decrement function is not functioning properly on the initial click, but seems to work fine after

React state updates not functioning properly. The increase and decrease functions are not working on the first click but work after subsequent clicks. The subtotal value is consistently incorrect, showing as 94.50 instead of the expected 105 for a quanti ...

JavaScript: A step-by-step guide to extracting the file name and content from a base64 encoded CSV

I have a base64 string that was generated by encoding a csv file, const base64 = 'LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTExNDc2MDgwNjM5MTM4ODk4MTc2NTYwNA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJmaWxlIjsgZmlsZW5hbWU9ImNoYXJ0T2ZBY2NvdW50LmNzd ...

Accessing elements in AngularJS through ng-click function

According to information provided in this answer, it is necessary to pass the $event object to the ng-click function in order to access the target element. $scope.setMaster = function(obj, $event){ console.log($event.target); } Although using event.t ...

Declaring types globally in Visual Studio Code for JavaScript programming

My /typings/$app.d.ts file has the following structure: declare class App { test: object } export const $app: App; https://i.sstatic.net/3HW7M.png In order to enable intellisense, I have to auto-import it, resulting in a line like this at the begin ...

What causes certain images to have unspecified height and width measurements?

Currently, I am in the process of extracting image sizes from a website using a module called scraperjs. Most images have their height and width attributes defined, but some do not, resulting in the returned value being "undefined". How can I retrieve the ...

Setting up a simple configuration for WebGl and Javascript

I am currently using OSX 10.9.5 (Mavericks) and following a WebGL tutorial script provided on . I copied and pasted the code from the tutorial into TextEdit and saved it as HTML with the following file structure: webgl | +--index.html | ...

A guide on how to cycle through and modify key-value pairs using a Patch Request in MongoDB

I am working on configuring a patch request for the endpoint "/api/user?username=idHere". This patch request should accept a JSON body and update the user in MongoDB with the new key-value pairs. Currently, the line "{$set: {key: req.body[ ...

Automatically adjusting maps according to internal criteria

I have an example of a map that looks like this const Map = new Map().set('123', [ [ 'foo', 'bar' ] ]).set('456', [ [ 'baz', 'qux' ], [ 'quux', 'corge' ] ]); /* The structure ...

What is the process for indicating an option as "chosen" within Embedded JavaScript Templating (EJS)?

I've been working on a function that allows users to modify each other's data, including the ability to change roles. I'm having trouble getting the select form to display the current role of a user with the "selected" attribute. This is wh ...

Creating dynamic input fields on button click in AngularJS: Step-by-step guide

Currently, I am working on a project that involves a dropdown menu. Here is a sneak peek: https://i.sstatic.net/ghwr8.jpg In the dropdown menu, users are able to select from various input types such as TextBox, Checkbox, Radio button, and Drop down. Addi ...

The input value fails to update after the method is called

I am working on developing a todo-list application and here is the code I have so far: HTML: <div class="divPadder"> <input ref="makePlaceholderEmpty" class="inputBoxSize" type="text" :placeholder="placeholder"v-model="task"> <ul> ...

Updating the background color and adjusting the main content background on a WordPress site

After spending nearly an hour searching for a solution to my problem with no luck, I've come to the conclusion that most YouTube videos are not helpful at all. My website is built on WordPress and I am attempting to change the background color and mai ...

Attempt to make another REST API request

For our project, we are using a Node JS HTTP Post request to access a REST API provided by a payment service provider. I am wondering if it is considered best practice to retry the request a specific number of times in case the API is down or not respondin ...

The confirmation dialogue is malfunctioning

Need some assistance with my code. I have a table where data can be deleted, but there's an issue with the dialog box that pops up when trying to delete an item. Even if I press cancel, it still deletes the item. Here is the relevant code snippet: ec ...

The functionality of the jQuery scroll feature appears to be malfunctioning

I am trying to implement a scroll event and have written the following code: <script type="text/javascript> $(function () { $(window).scroll(function () { alert($("body").scrollTop()); }); }); ...