f2-manifest-loader
v0.2.0
Published
webpack module for F2 that generates app manifests
Downloads
2
Readme
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 manifestsfilename
: String - name of the generated manifest files. Default:<app_id>_manifest.js(on)
appclass
: String (required, default:dist/[name].js
) - path to the built appclassstyles
: [String] - array of app styles to be includedcommonScripts
: [String] - array of common scripts to be included before the appclasscommonStyles
: [String] - array of common styles to be included before app stylesinlineScripts
: [String] - array of inline scripts to be includedhtml
: 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');
}
};