@travetto/email-compiler 6.0.0-rc.2 → 6.0.1
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/README.md +1 -0
- package/package.json +10 -10
- package/src/util.ts +10 -9
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ This is primarily a set of command line tools for compiling and developing templ
|
|
|
19
19
|
The templating process involves loading various assets (html, css, images), and so there is provision for asset management and loading. The templating config allows for specifying asset paths, with the following paths (in order of precedence):
|
|
20
20
|
1. `%ROOT%/resources/email`
|
|
21
21
|
1. `@travetto/email-{engine}/resources/email`
|
|
22
|
+
|
|
22
23
|
When looking up a resources, every asset folder is consulted, in order, and the first to resolve an asset wins. This allows for overriding of default templating resources, as needed. The compilation process will convert `.email.html` files into `.compiled.html`, `.compiled.text` and `.compiled.subject` suffixes to generate the outputs respectively.
|
|
23
24
|
|
|
24
25
|
## Template Extension
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/email-compiler",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.1",
|
|
4
4
|
"description": "Email compiling module",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -26,20 +26,20 @@
|
|
|
26
26
|
"directory": "module/email-compiler"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^6.0.
|
|
30
|
-
"@travetto/di": "^6.0.
|
|
31
|
-
"@travetto/email": "^6.0.
|
|
32
|
-
"@travetto/image": "^6.0.
|
|
33
|
-
"@travetto/runtime": "^6.0.
|
|
34
|
-
"@travetto/worker": "^6.0.
|
|
35
|
-
"@types/inline-css": "^3.0.
|
|
29
|
+
"@travetto/config": "^6.0.1",
|
|
30
|
+
"@travetto/di": "^6.0.1",
|
|
31
|
+
"@travetto/email": "^6.0.1",
|
|
32
|
+
"@travetto/image": "^6.0.1",
|
|
33
|
+
"@travetto/runtime": "^6.0.1",
|
|
34
|
+
"@travetto/worker": "^6.0.1",
|
|
35
|
+
"@types/inline-css": "^3.0.4",
|
|
36
36
|
"html-entities": "^2.6.0",
|
|
37
37
|
"inline-css": "^4.0.3",
|
|
38
38
|
"purgecss": "^7.0.2",
|
|
39
|
-
"sass": "^1.
|
|
39
|
+
"sass": "^1.93.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@travetto/cli": "^6.0.
|
|
42
|
+
"@travetto/cli": "^6.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@travetto/cli": {
|
package/src/util.ts
CHANGED
|
@@ -13,29 +13,30 @@ type Tokenized = {
|
|
|
13
13
|
|
|
14
14
|
const SUPPORT_SRC = /(?:support|src)\//;
|
|
15
15
|
|
|
16
|
+
const HTML_CSS_IMAGE_URLS = [
|
|
17
|
+
/(?<pre><img[^>]src=\s{0,10}["'])(?<src>[^"{}]{1,1000})/g,
|
|
18
|
+
/(?<pre>background(?:-image)?:\s{0,10}url[(]['"]?)(?<src>[^"'){}]{1,1000})/g
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const EXT = /[.]email[.]tsx$/;
|
|
22
|
+
|
|
16
23
|
/**
|
|
17
24
|
* Email compile tools
|
|
18
25
|
*/
|
|
19
26
|
export class EmailCompileUtil {
|
|
20
|
-
static #HTML_CSS_IMAGE_URLS = [
|
|
21
|
-
/(?<pre><img[^>]src=\s{0,10}["'])(?<src>[^"{}]{1,1000})/g,
|
|
22
|
-
/(?<pre>background(?:-image)?:\s{0,10}url[(]['"]?)(?<src>[^"'){}]{1,1000})/g
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
static #EXT = /[.]email[.]tsx$/;
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Is file a template?
|
|
29
30
|
*/
|
|
30
31
|
static isTemplateFile(file: string): boolean {
|
|
31
|
-
return
|
|
32
|
+
return EXT.test(file);
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/**
|
|
35
36
|
* Generate singular output path given a file
|
|
36
37
|
*/
|
|
37
38
|
static buildOutputPath(file: string, suffix: string, prefix?: string): string {
|
|
38
|
-
const res = (SUPPORT_SRC.test(file) ? file.split(SUPPORT_SRC)[1] : file).replace(
|
|
39
|
+
const res = (SUPPORT_SRC.test(file) ? file.split(SUPPORT_SRC)[1] : file).replace(EXT, suffix);
|
|
39
40
|
return prefix ? path.join(prefix, res) : res;
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -133,7 +134,7 @@ export class EmailCompileUtil {
|
|
|
133
134
|
* Inline image sources
|
|
134
135
|
*/
|
|
135
136
|
static async inlineImages(html: string, opts: EmailTemplateResource): Promise<string> {
|
|
136
|
-
const { tokens, finalize } = await this.tokenizeResources(html,
|
|
137
|
+
const { tokens, finalize } = await this.tokenizeResources(html, HTML_CSS_IMAGE_URLS);
|
|
137
138
|
const pendingImages: [token: string, ext: string, stream: Buffer | Promise<Buffer>][] = [];
|
|
138
139
|
|
|
139
140
|
for (const [token, src] of tokens) {
|