@travetto/email-compiler 3.3.6 → 3.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/compiler.ts +3 -15
- package/src/util.ts +4 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-compiler",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.8",
|
|
4
4
|
"description": "Email compiling module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"directory": "module/email-compiler"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/base": "^3.3.
|
|
30
|
-
"@travetto/config": "^3.3.
|
|
31
|
-
"@travetto/di": "^3.3.
|
|
32
|
-
"@travetto/email": "^3.3.
|
|
33
|
-
"@travetto/image": "^3.3.
|
|
29
|
+
"@travetto/base": "^3.3.4",
|
|
30
|
+
"@travetto/config": "^3.3.5",
|
|
31
|
+
"@travetto/di": "^3.3.4",
|
|
32
|
+
"@travetto/email": "^3.3.5",
|
|
33
|
+
"@travetto/image": "^3.3.4",
|
|
34
34
|
"@types/inline-css": "^3.0.1",
|
|
35
35
|
"html-entities": "^2.4.0",
|
|
36
36
|
"inline-css": "^4.0.2",
|
|
37
37
|
"purgecss": "^5.0.0",
|
|
38
|
-
"sass": "^1.
|
|
38
|
+
"sass": "^1.68.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@travetto/cli": "^3.3.
|
|
41
|
+
"@travetto/cli": "^3.3.6"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"@travetto/cli": {
|
package/src/compiler.ts
CHANGED
|
@@ -22,25 +22,13 @@ export class EmailCompiler {
|
|
|
22
22
|
}
|
|
23
23
|
const root = (await import(entry.outputFile)).default;
|
|
24
24
|
const og: EmailCompileSource = await root.wrap();
|
|
25
|
-
const res = {
|
|
25
|
+
const res: EmailCompileContext = {
|
|
26
26
|
file: entry.sourceFile,
|
|
27
27
|
module: entry.module,
|
|
28
|
+
images: {},
|
|
29
|
+
styles: {},
|
|
28
30
|
...og
|
|
29
31
|
};
|
|
30
|
-
|
|
31
|
-
const mod = RootIndex.getModule(entry.module)!;
|
|
32
|
-
|
|
33
|
-
const resourcePaths = [
|
|
34
|
-
path.resolve(mod.sourcePath, 'resources'),
|
|
35
|
-
path.resolve(RootIndex.manifest.workspacePath, 'resources')
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
const styles = res.styles ??= {};
|
|
39
|
-
(styles.search ??= []).push(...resourcePaths);
|
|
40
|
-
|
|
41
|
-
const images = res.images ??= {};
|
|
42
|
-
(images.search ??= []).push(...resourcePaths);
|
|
43
|
-
|
|
44
32
|
return res;
|
|
45
33
|
}
|
|
46
34
|
|
package/src/util.ts
CHANGED
|
@@ -137,11 +137,11 @@ export class EmailCompileUtil {
|
|
|
137
137
|
static async inlineImages(html: string, opts: EmailTemplateImageConfig): Promise<string> {
|
|
138
138
|
const { tokens, finalize } = await this.tokenizeResources(html, this.#HTML_CSS_IMAGE_URLS);
|
|
139
139
|
const pendingImages: [token: string, ext: string, stream: Readable | Promise<Readable>][] = [];
|
|
140
|
-
const
|
|
140
|
+
const resource = new FileResourceProvider({ includeCommon: true, paths: opts.search ?? [] });
|
|
141
141
|
|
|
142
142
|
for (const [token, src] of tokens) {
|
|
143
143
|
const ext = path.extname(src);
|
|
144
|
-
const stream = await
|
|
144
|
+
const stream = await resource.readStream(src);
|
|
145
145
|
pendingImages.push([token, ext, /^[.](jpe?g|png)$/.test(ext) ?
|
|
146
146
|
ImageConverter.optimize(ext === '.png' ? 'png' : 'jpeg', stream) : stream]);
|
|
147
147
|
}
|
|
@@ -183,7 +183,7 @@ export class EmailCompileUtil {
|
|
|
183
183
|
styles.push(opts.global);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
const resource = new FileResourceProvider(opts.search ?? []);
|
|
186
|
+
const resource = new FileResourceProvider({ includeCommon: true, paths: opts.search ?? [] });
|
|
187
187
|
const main = await resource.read('/email/main.scss').then(d => d, () => '');
|
|
188
188
|
|
|
189
189
|
if (main) {
|
|
@@ -191,9 +191,7 @@ export class EmailCompileUtil {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
if (styles.length) {
|
|
194
|
-
const compiled = await this.compileSass(
|
|
195
|
-
{ data: styles.join('\n') },
|
|
196
|
-
[...opts.search ?? []]);
|
|
194
|
+
const compiled = await this.compileSass({ data: styles.join('\n') }, resource.paths);
|
|
197
195
|
|
|
198
196
|
// Remove all unused styles
|
|
199
197
|
const finalStyles = await this.pruneCss(html, compiled);
|