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.

Extend the src field so that it can take multiple directory locations

See original GitHub issue

Hi, I have an issue where I have created an express.js web application. I have also installed the material-components-web package using npm install. NPM installed that under node_modules. With the express project setup there is also a local public/stylesheet folder where the project’s sass files are located.

In my app.js I have some lines of code as follows:

app.use(sassMiddleware({
  src: path.join(__dirname, 'public'),
  dest: path.join(__dirname, 'public'),
  indentedSyntax: true, // true = .sass and false = .scss
  sourceMap: true
}));

I would like to set the src field so that it can take an array of strings which represent all the folders where node-sass should look for to pick up the required sass files. At the moment, only one can be specified ie public in the example above. What this means is that I cannot do

@import @material/buttons/mdc-button

I keep getting errors saying that it cannot find the sass files for mdc-button:

GET / 304 424.401 ms - -
[sass]  error: File to import not found or unreadable: @material/button/mdc-button.

Looking at your source code it seems that src can only take a string and not an array of strings:

import * as sass from "node-sass";
import * as express from "express";

interface Options extends sass.Options {
    /**
     * 
     */
    src: string;
    /**
     * 
     */

Does string contain a comma separated values of paths ie “public,node_modules” or is just a single path value ie “public”. From my experiments, it seems the latter.

I hoped that made sense. I am not really a frontend developer so I maybe approaching this incorrectly.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
am11commented, Nov 12, 2019

@co-category, if you set debug: true, it will show where it is trying to locate the source file and failing.

By the looks of it, src: path.join(__dirname, 'public'), was changed to src: __dirname, (for some reason?), which might explain.

If it does not help, please provide an SSCCE. In this case, a zip file (or git-gist or a script file), resulting in the structure of your project (location of sass, css files), how to run, how to use it, what is the actual behavior and the expected behavior.

0reactions
mikail-khancommented, Nov 12, 2019

@am11 got it working now after your hint, correct code should have been:

app.use(sassMiddleware({
  src: path.join(__dirname, 'public'),
  includePaths: ['public', 'node_modules'],
  dest: path.join(__dirname, 'public'),
  indentedSyntax: true, // true = .sass and false = .scss
  sourceMap: true
}));

Thank you 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Separate "include" and "src" folders for application-level ...
I place include (header) and source files in the same directory (folder). I create different folders for different themes. I get frustrated when...
Read more >
Content roots | IntelliJ IDEA Documentation
Click Modules under the Project Settings section, and then select a module. If there are several content roots in this module, select the...
Read more >
Content Configuration
Configuring source paths. Tailwind CSS works by scanning all of your HTML, JavaScript components, and any other template files for class names, ...
Read more >
Working With Files and Directories – The Unix Shell
Creating directories. We now know how to explore files and directories, but how do we create them in the first place? In this...
Read more >
TSConfig Reference - Docs on every TSConfig option
The value of extends is a string which contains a path to another configuration file to inherit from. The path may use Node.js...
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

No results found

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