-
Notifications
You must be signed in to change notification settings - Fork 36
Using Mailer inside another package support #51
Conversation
…side another package. Also changed the overwriting of Mailer.init function that prevented several init calls, necessary if you use it in a package and in the app
Thanks for this! I'm gonna check it out in further detail, but it looks good at first look. But please remind me: is |
At the time I did this, I think it was a no go, but now in the Meteor docs at Assets there is this line
So it should be ok to read everything with the Assets API now, but you may have to pass to the Mailer Template a reference to the upper package Assets Object |
Upgrade to meteorhacks:ssr 2.2.0
Hi, |
if (!Package['chrisbutler:node-sass']) { | ||
Utils.Logger.warn('Sass support is opt-in since lookback:[email protected]. Please add chrisbutler:node-sass from Atmosphere and try again.', TAG); | ||
return Utils.readFile(scss); | ||
} | ||
|
||
const file = path.join(ROOT, scss); | ||
const file = packageFolderName ? | ||
path.join(PACKAGES_ROOT, packageName, relativePathFromApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like packageName
isn't defined here?
Added some notes to the code. |
👍 |
Feat/inside package support
I am having issues with the SCSS files, because they are not found. |
Hi @mcoenca, hopefully the PR I did to your branch will accelerate the merging of this branch. Bests |
By the way, I am currently using this in dev but I plan to put it in production later today. I will let you know if I find some other issue within it while developing or deploying. |
Great, thanks for testing. |
@johanbrook @mcoenca, I am using the branch from where I did the PR to your branch in production and everything seems to be working just fine. |
@johanbrook @mcoenca, the only thing might be missing is some documentation on the topic. For future major version, I think might be better to refactor this to use just |
Sorry was on vacation, will answer your questions and merge carlos PR in following days. Best. |
Bring branch to master HEAD and Fix CSS
This has not been tested on production, but I have an older version of exactly the same ideas that was working fine, and as this one works fine on development, others env should (ahem) be OK.
The idea is that inside the bundled folder in production (build), the packages assets are available through programs/server/assets/packages/
packageAuthorName_packageName
/pathToExportedAsset
We cannot access the package name from inside the package. So i just decided an easy way to do it would be to give all mail templates an optional packageFolderName field corresponding to
packageAuthorName_packageName
, and then add corresponding constants and methods to the chain of util.readFile etc...Watch out if you are using
Mailer
inside a package and inside your main app. There is only one globalMailer
variable, so you will override previousMailer.config
if you call it more than once.But now you can call several
Mailer.init
! (Btw @johanbrook I am not sure i did not break something by allowing to callMailer.init
several times: was your renaming and overwriting of the init function intentional ?)At the end, Usage
/your_package/package.js
/your_package/server/mailer_init.js
And then voila you can use
Mailer.send({template: 'newQuestAnswer'}))
from within the bridges:notifications packageAnd you can still use
Mailer.init
in your main app with different templates. (watch out for configs)Best,