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.

I tried to apply css as stated here but no style appears in the head after rendering. Here’s how I am trying to it.

.js file

const viewsDir = `${__dirname}/Views`;
const template = new EmailTemplates({
    views: {
        root: viewsDir,
        options: {
                    extension: 'ejs',
               },
         },
          juice: true,
           juiceResources: {
           preserveImportant: true,
           webResources: {
                     relativeTo: path.resolve(viewsDir),
            }
    }
});

In the .ejs file, I have added: <link rel="stylesheet" href="/style.css" data-inline="data-inline"> to the head tag.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
niftylettucecommented, Jul 12, 2018

Perhaps set const dir = path.resolve(viewsDir) and then console.log('dir', dir); to make sure that the path to the viewsDir is correct. Sometimes it is different based off what directory you start the process from.

0reactions
vikkio88commented, Feb 4, 2020

I know that I am like 1 year and a half late to the party, but I had this error and I fixed it.

seems like you nested this


juice: true,
juiceResources: {
  preserveImportant: true,
  webResources: {
    relativeTo: path.resolve(viewsDir),
  }
}

under views

Instead on the example code on the docs is on the root object. This might have been the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is my CSS style not being applied? - Stack Overflow
I went to solution explorer (press Ctrl+Alt+L) and searched gt.css (enter your css filename). Right click on your css filename and then on ......
Read more >
How to Troubleshoot CSS Not Working - WPForms
Troubleshooting CSS · Trying a Different Browser · Asking Your Host if They Have a Cache · Trying a Different Internet Source.
Read more >
How to fix CSS not linking to your HTML document
How to fix CSS not linking to your HTML document · Make sure that you add the rel attribute to the link tag...
Read more >
Help! My CSS Isn't Working! - meyerweb.com
Help! My CSS Isn't Working! · First, Be Sure You're Right · Too Many Spaces · Too Much HTML · External Problems ·...
Read more >
CSS Style Not Being Applied (Example) | Treehouse Community
Okay so at first glance, I see two possible problems. In your HTML the link for your font has a space in the...
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