mjmlio / gulp-mjml

Add Gulp to your MJML workflow!
MIT License
162 stars 38 forks source link

Relatives buggy with mj-include #32

Closed deanorhan closed 6 years ago

deanorhan commented 6 years ago

Having problems with the new changes for relative URLs in mj-inlcude tags. Compiling with the MJML commandline tool works but when using gulp-mjml we get the error:

Error: ENOENT: no such file or directory, open '../freemarker/mjml/ommon/Attributes.mjml' at Object.fs.openSync (fs.js:646:18) at Object.fs.readFileSync (fs.js:551:33) at checkIncludeHash (/Users/dean/Documents/Workspace/bobe/build/gulpfile.js:447:29) at /Users/dean/Documents/Workspace/bobe/build/gulpfile.js:393:24 at DestroyableTransform.modifyFile [as _transform] (/Users/dean/Documents/Workspace/bobe/node_modules/gulp-tap/lib/tap.js:53:11) at DestroyableTransform.Transform._read (/Users/dean/Documents/Workspace/bobe/node_modules/readable-stream/lib/_stream_transform.js:182:10) at DestroyableTransform.Transform._write (/Users/dean/Documents/Workspace/bobe/node_modules/readable-stream/lib/_stream_transform.js:170:83) at doWrite (/Users/dean/Documents/Workspace/bobe/node_modules/readable-stream/lib/_stream_writable.js:406:64) at writeOrBuffer (/Users/dean/Documents/Workspace/bobe/node_modules/readable-stream/lib/_stream_writable.js:395:5) at DestroyableTransform.Writable.write (/Users/dean/Documents/Workspace/bobe/node_modules/readable-stream/lib/_stream_writable.js:322:11)

When we use the tag:

<mj-include path="../common/Attributes.mjml" />

iRyusa commented 6 years ago

Error: ENOENT: no such file or directory, open '../freemarker/mjml/ommon/Attributes.mjml' Looks like a typo ommon

Did you tried the 2.3 version ?

deanorhan commented 6 years ago

We are using 2.3.0.

iRyusa commented 6 years ago

In 2.3 relative is now from file that does the include instead of the current pwd. Did it works on older gulp-mjml ?

Edit: we need more information on file structure, or just upload a repository to reproduce so we can check few things :)

deanorhan commented 6 years ago

Yes it did. Previously we had the URL as ../freemarker/mjml/email/common/Attributes.mjml in the include, since this was relative to the location of the gulp file. Since updating we've been updating our templates to be relative from the actual file, i.e. ../common/Attributes.mjml. This is breaking with that error I listed above.

Strange thing is it works when we change the relative to be ../../../../freemarker/mjml/email/common/Attributes.mjml. So all the way down and all the way back up.

iRyusa commented 6 years ago

Ew... weird, can you try to create a git repo with bare file to reproduce the bug so I can check ?

deanorhan commented 6 years ago

I'll try a get a repo up, workspace need to be condensed quite a bit.

deanorhan commented 6 years ago

While trying to simplify things I've found that its actually some of our other build steps causing the issue. It wasn't updated with the change for includes being relative to the files properly.

Sorry for this.

iRyusa commented 6 years ago

👌 then