Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Coverage

Plugin AngularJS template cache

Plugin to build AngularJS template cache.

Changelog

Installation

Using npm:

npm install --save-dev @rollup-extras/plugin-angularjs-template-cache

Example

Basic:

import templatesCache from '@rollup-extras/plugin-angularjs-template-cache';

export default {
	input: 'src/index.js',

    output: {
        format: 'es',
        dir: 'dest'
    },

	plugins: [
        templatesCache('./views/**/*.html'),
    ],
}

With useImports = true and rootDir:

import templatesCache from '@rollup-extras/plugin-angularjs-template-cache';
import htmlImport from 'rollup-plugin-html';

export default {
	input: 'src/index.js',

    output: {
        format: 'es',
        dir: 'dest'
    },

	plugins: [
        htmlImport({include: '**/*.html'}),
        templatesCache({ templates: './src/**/*.html', rootDir: './src', useImports: true}),
    ],
}

Configuration

type AngularTemplatesCachePluginOptions = {
    templates?: string | string[], // defaults to ./**/*.html, glob to get files into templateCache
    watch?: boolean, // true by default
    rootDir?: string, // default to '.', root directory from which the plugin will construct template URIs (IDs)
    transformTemplateUri?: (uri: string) => string, // last chance to transform template URI before actually using it in `templateCache.put` call
    processHtml?: (html: string) => string, // function to process html templates, for example `htmlmin`, not applied when `useImports = true`
    pluginName?: string, // defaults to '@rollup-extras/plugin-angularjs-template-cache'    
    angularModule?: string, // 'templates' by default, angular module name
    standalone?: boolean, // true by default, true if the plugin needs to create a module and false to just retrieve it
    module?: string, // 'templates' by default, javascript module name, import not automatically injected into bundle
    importAngular?: boolean, // default true, defines if it is required to import Angular or to use a global
    autoImport?: boolean, // false by default, automatically import generated module (useful for standalone module referenced by name)
    verbose?: boolean | 'list-filenames', // false by default
    useImports?: boolean, // false by default, instead of reading files from the filesystem generate imports to get them through rollup pipeline. this probably requires additional plugins like `rollup-plugin-html`
    transformHtmlImportsToUris?: boolean // false by default, if true replaces template content with its Uri when using bare import
} | string | string[];

Prior Art

License

MIT