node.jsember.jsbroccolijs

How to run my node script as one of the ember's build tasks?


I am working in an ember application. From what I understood, it builds the application using Broccoli. I have a requirement where I need to process some files in the application by running a node script before the building process starts. Now I am running the node script separately and then I start the ember server. What is the right way to achieve it? Can I make it as one of the tasks during ember build process? Where should I maintain the node file in the directory?


Solution

  • I would recommend an in-repo addon that implements preBuild or postBuild Ember CLI Addon hooks. Addon hooks are badly documented but there are some usage examples by other addons. E.g. ember-cli-deploy-build-plus uses postBuild hook to remove some files from build output.

    An more advanced option would be implementing a broccoli plugin and using that one in a treeFor* hook. This makes especially sense if your custom script needs to add / remove files from the build. ember-cli-addon-docs is a great example for that usage.