Search code examples
mean.io

Using MEAN.IO how will my package's assets get aggregated?


I'm not an experienced Javascript application developer, however, I've recently been learning some MEAN using http://mean.io/#!/ as my scaffolding.

I can see that the out of the box assets are listed in:

/server/config/assets.json 

and when the app is running the referenced assets get combined into client side files:

/modules/aggregated.css
/modules/aggregated.js

When I create a package using MEAN.IO's CLI:

mean package myPackage;

and start including css or scripts in this package, presumably it is bad practice to then put the packages assets into the application's assets.json as these packages are supposed to be reusable modules that could be added to someone else's MEAN application.

What's the right place to reference the new package's assets so that they are added into the aggregration process?


Solution

  • you want to add css or js files into your packages.

    If so, it's easy. As the doc says in "Assets and Aggregation" http://learn.mean.io/#mean-packages-assets-and-aggregation

    you should use

    //Adding another library - global by default is false
    MyPackage.aggregateAsset('js','jquery.min.js', {global:true});
    //Adding some css to the mean project
    MyPackage.aggregateAsset('css','default.css');