Skip to content

Commit

Permalink
change css-inliner for inline-css
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bioux committed Apr 3, 2020
1 parent 1f56b88 commit cb265e6
Show file tree
Hide file tree
Showing 5 changed files with 8,882 additions and 91 deletions.
10 changes: 4 additions & 6 deletions lib/adapters/handlebars.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as handlebars from 'handlebars';
import * as CSSInliner from 'css-inliner';
import * as inlineCss from 'inline-css';
import * as glob from 'glob';
import { get } from 'lodash';

Expand Down Expand Up @@ -66,7 +66,7 @@ export class HandlebarsAdapter implements TemplateAdapter {

if (runtimeOptions.partials) {
const files = glob.sync(path.join(runtimeOptions.partials.dir, '*.hbs'));
files.forEach(file =>
files.forEach((file) =>
precompile(file, () => {}, runtimeOptions.partials),
);
}
Expand All @@ -79,10 +79,8 @@ export class HandlebarsAdapter implements TemplateAdapter {
},
);

const { dir } = path.parse(templatePath);
const inliner = new CSSInliner({ directory: dir });

inliner.inlineCSSAsync(rendered).then(html => {
inlineCss(rendered, { url: ' ' }).then((html) => {
console.log(html);
mail.data.html = html;
return callback();
});
Expand Down
8 changes: 3 additions & 5 deletions lib/adapters/pug.adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as path from 'path';
import { get } from 'lodash';
import { renderFile } from 'pug';
import * as CSSInliner from 'css-inliner';
import * as inlineCss from 'inline-css';

/** Interfaces **/
import { MailerOptions } from '../interfaces/mailer-options.interface';
Expand Down Expand Up @@ -31,10 +31,8 @@ export class PugAdapter implements TemplateAdapter {
return callback(err);
}

const { dir } = path.parse(templatePath);
const inliner = new CSSInliner({ directory: dir });

inliner.inlineCSSAsync(body).then(html => {
inlineCss(body, { url: ' ' }).then((html) => {
console.log(html);
mail.data.html = html;
return callback();
});
Expand Down
Loading

0 comments on commit cb265e6

Please sign in to comment.