Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to aggregate JS assets on Mean.io

I'm new to Mean.io and I'm trying to aggregate an external .js file to my package but I'm doing it wrong because it is not being added to aggregated.js.

This is what I've done:

importer.register(function(app, auth, database) {

  importer.aggregateAsset('js', 'xml2json.min.js');

  //We enable routing. By default the Package Object is passed to the routes
  importer.routes(app, auth, database);

  //We are adding a link to the main menu for all admin users
  VavelImporter.menus.add({
    title: 'importer example page',
    link: 'importer example page',
    roles: ['admin'],
    menu: 'main'
  });

  return importer;
});

The important line is: importer.aggregateAsset('js', 'xml2json.min.js'); My asset (xml2json.min.js) is located under importer/public/assets/js/xml2json.min.js.

I need someone to explain me where to put that asset so Mean.io locates that file.

Thanks.

like image 734
Leonardo Lanchas Avatar asked Oct 20 '22 21:10

Leonardo Lanchas


1 Answers

It turns out it was aggregating assets well. As Mean.io docs say

All assets such as images, javascript libraries and css stylesheets should be within public/assets/{img|js|css}/ of the package file structure.

By default all javascript is automatically wrapped within an anonymous function unless given the option {global:true} to not enclose the javascript within a contained scope.

It's then when you are able to use the external JS functionality.

like image 78
Leonardo Lanchas Avatar answered Oct 27 '22 09:10

Leonardo Lanchas