Asset Packaging and the goodies from SharePoint Framework 1.4

Asset packaging is an excellent feature for SPFx solutions, until now the manifest and script files had to be hosted in a CDN like Azure or Office 365 CDN. Handling the hosting was a problem to if you want to distribute or sell the solution, with the solution being recompiled to be used in different tenants.

With Asset Packaging the SPFx solution files are deployed to a central CDN without the need to manually specify the url in the solution source code.

The Asset Packaging was released along with the Site Collection App Catalog and both features combined provide the same type of functionality that was provided by the sand box solutions, with all the files included into one package and being able to be installed per site collection and not globally.

SPFx Asset Packaging

How to update to the latest SPFx version

Update an existent project

To use the latest version of the SharePoint Framework you will have to update the packages of your project to do it follow the steps bellow

  1. Open the command line in the project folder
  2. Type npm outdated to get a list of all the outdated packages; from the list you will get:
    • Current version installed in your project
    • Version requested by your project (available in package.json)
    • Latest version available

    Outdated SPFx Packages
    SharePoint Framework packages are identified by the prefix @microsoft/sp-

  3. For each outdated package run the command npm install mypackage@newversion –save
  4. Run the command gulp --update to update your config.json to the latest version
  5. Once you get all the packages updated run the command gulp clean
  6. Build your project again using the command gulp build and verify if the newer version didn’t cause any errors.

Update the Yeoman generator

If you want to start a new project from scratch make sure you have the generator 1.4 installed, to do it follow these steps:

  1. Open the command line and run the command npm -g outdated
    Outdated SPFx Packages
  2. To install the latest version run the command npm install @microsoft/generator-sharepoint@latest -g
  3. Run the command yo @microsoft/sharepoint to create a new project and follow the wizard

How to enable the Asset Packing

If you are starting a new project after updating the yeoman generator you don’t need to do anything, the solution will be created with this functionality enabled by default.

If you are migrating to the version 1.4 and want to take advantage of the Asset Packaging do the following:

  1. Open your project in your code editor
  2. Expand the config folder
  3. Open the package-solution.json
  4. Add the property includeClientSideAssets with the value true to the node solution
    Asset Packaging Configuration
  5. To package the solution to be installed in your run the command gulp bundle --ship followed by gulp package-solution --ship

When installing the solution with the Asset Packaging enabled you will notice that the content will be provided by the domain SharePoint Online.

Asset Packaging Instalation

How to use the Site Collection App Catalog

With the site collection app catalog administrators will be able to make Add-ins and SPFx extensions available per site collection which will allow different and independent versions in the same tenant.

To enable the Site Collection App Catalog you will need to install the SharePoint Online Management Shell. Once you get it installed follow the steps bellow.

  1. Connect to your Office 365 running this command Connect-SPOService -Url "https://contoso-admin.sharepoint.com"
  2. To crearte the site collection app catalog run the command Add-SPOSiteCollectionAppCatalog -Site https://contoso.sharepoint.com/sites/rome
    If you want to disable the site collection app catalog for a site collection run the command
    Remove-SPOSiteCollectionAppCatalog -Site https://contoso.sharepoint.com/sites/rome

You can get more information about the features released in SPFx 1.4 here.


2 Responses to “Asset Packaging and the goodies from SharePoint Framework 1.4”

  1. […] On your project go to the config folder and open the package-solution.json and confirm if the property includeClientSideAssets exists in the solution, if it doesn’t exist it means that you are not using SPFx 1.4 to update your project follow the steps described in this article. […]

    Reply
  2. Tom

    September 5, 2019

    Hi, I’m getting error “.ts(44,31): error TS1005: ‘}’ expected” when running ‘gulp bundle –ship’ in command line via visual studio. Getting error that build has failed and can’t figure out why…can you help?

    Thanks!
    Tom

    Reply

Leave a Reply to How to add Google Analytics to the Modern SharePoint | HANDS ON SharePoint


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.

%d bloggers like this: