f2-manifest-loader

0.2.0 • Public • Published

npm version Build Status Coverage Status

F2 Manifest Loader

This package enables the automatic generation of app manifests using F2 and webpack

  • Produces JS and JSON manifests
  • Scripts and styles automatically have a cachebuster appended

Usage

loaders: [
    // ...
    {
        test: /\.jsx?/,
        loader: 'f2-manifest-loader',
        include: 'src/appclasses',
        options: {
            dest: path.join(__dirname, 'dist/manifests'),
            filename: 'manifest',
            appclass: path.join(
                'http://my-server.com', 
                'dist/my-app.js'
            ),
            styles: [path.join(
                'http://my-server.com', 
                'dist/my-app.css'
            )],
            commonScripts: ['http://my-cdn.com/bootstrap.js'],
            commonStyles: ['http://my-cdn.com/nice-styles.css'],
            inlineScripts: ['window.myObject = {hello: "world"}'],
            html: '<my-app class="my-class"></my-app>'
        }
    }
]

Produces:

// dist/manifests/manifest.js
F2_jsonpCallback_com_open_f2_app_one({
    "inlineScripts":[window.myObject = {hello: "world"}],
    "scripts":[
        "http:/my-cdn.com/bootstrap.js?v=1517269612205",
        "http:/my-server.com/dist/my-app.js?v=1517269612205"
    ],
    "styles":[
        "http:/my-cdn.com/nice-styles.css?v=1517269612205",
        "http:/my-server.com/dist/my-app.css?v=1517269612205"
    ],
    "apps":[{
        "html":"<my-app class="my-class"></my-app>"
    }]
})

options

These options are available on top of the standard Webpack loader options:

  • dest: String (required, default: null) - path to destination folder for app manifests
  • filename: String - name of the generated manifest files. Default: <app_id>_manifest.js(on)
  • appclass: String (required, default: dist/[name].js) - path to the built appclass
  • styles: [String] - array of app styles to be included
  • commonScripts: [String] - array of common scripts to be included before the appclass
  • commonStyles: [String] - array of common styles to be included before app styles
  • inlineScripts: [String] - array of inline scripts to be included
  • html: String (default: <app-id /> lower-kebab-cased app id as declared in the appclass) - app HTML

Ignoring files

Include f2-manifest-loader-ignore (case sensitive) in a comment in any source file to have that file ignored by the loader.

// f2-manifest-loader-ignore
 
F2.Apps['com_open_f2_ignored_app'] = class app {
    constructor(appConfig, appContent, root) {
        this.appConfig = appConfig;
        this.appContent = appContent;
        this.root = root;
    }
 
    init() {
        console.log('This app will not have its manifest generated');
    }
};

Package Sidebar

Install

npm i f2-manifest-loader

Weekly Downloads

1

Version

0.2.0

License

Apache-2.0

Unpacked Size

21.5 kB

Total Files

8

Last publish

Collaborators

  • pc2459
  • rekabnairb