JSPM

  • Created
  • Published
  • Downloads 321
  • Score
    100M100P100Q53961F
  • License MIT

Seznam IMA.js plugin for loading style

Package Exports

  • @ima/plugin-style-loader
  • @ima/plugin-style-loader/dist/cjs/main.js
  • @ima/plugin-style-loader/dist/esm/main.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ima/plugin-style-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@ima/plugin-style-loader

This is the plugin for loading 3rd party styles for the IMA.js application. You can visit our site https://imajs.io.

Installation

npm install @ima/plugin-style-loader --save
// /app/build.js

var vendors = {
    common: [
        '@ima/plugin-style-loader'
    ]
};

/*
Now is script loader plugin available as:

import { StyleLoaderPlugin, events, defaultDependencies } from '@ima/plugin-style-loader';
*/

Usage

import { Dispatcher } from '@ima/core';
import { StyleLoaderPlugin, events as StyleLoaderEvents } from '@ima/plugin-style-loader';

oc
    .get(StyleLoaderPlugin)
    .load('//www.example.com/style.css')
    .then((result) => {
        console.log('Style is loaded.', result.url);
    })
    .catch((error) => {
        console.log('Style failed to load.', error);
    });

oc
    .get(Dispatcher)
    .listen(StyleLoaderEvents.LOADED, (result) => {
        if (result.error) {
            console.log('Style is not loaded.', result.url);
        } else {
            console.log('Style is loaded.', result.url);
        }
    });