0.2.3 • Published 3 years ago

compilation-info-webpack-plugin v0.2.3

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
3 years ago

compilation-info-webpack-plugin

Plugin allowing to render compilation information as additional outputs.

:warning: This library is in an early stage and doesn't have API set in stone. Major changes can happen without warning. :warning:

Installation

  • npm install --save-dev webpack (dependencies)
  • npm install --save-dev compilation-info-webpack-plugin

Configuration

interface CompilationInfoPluginOptions {
    /**
     * Template rendered for each compilation. Template model is `Compilation`.
     */
    compilationTemplate?: CompilationInfoPluginTemplateOptions;
    /**
     * Template rendered for each entry point. Template model is `EntryPoint`.
     */
    entryPointTemplate?: CompilationInfoPluginTemplateOptions;
}
interface CompilationInfoPluginTemplateOptions {
    /**
     * Handlebars template string.
     */
    template: string;
    /**
     * Output filename. Allowed tokens:
     *  - Compilation: --
     *  - Entry point: [name]
     */
    output: string;
}

Configuration sample

Sample webpack configuration to print out all chunks as script tags for ASP.NET Core Razor Pages:

{
    plugins: [
        new CompilationInfoPlugin({
            entryPointTemplate: {
                output: '../../Pages/Generated/_[name].cshtml',
                template: `@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
{{#each chunks}}
{{#each files}}
<script src="~/assets/{{replace name '@' '@@'}}" asp-append-version="true"></script>
{{/each}}
{{/each}}
`
            }
        }),
    ]
};

Template model

interface Compilation {
    entryPoints: EntryPoint[];
}

interface EntryPoint {
    name: string;
    chunks: Chunk[];
}

interface Chunk {
    files: File[];
}

interface File {
    name: string;
}

Template omdel sample

{
    "entryPoints": [
        {
            "name": "main",
            "chunks": [
                {
                    "files": [
                        {
                            "name": "main.js"
                        }
                    ]
                }
            ]
        }
    ]
}
0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago