Skip to content

Latest commit

 

History

History
213 lines (161 loc) · 3.3 KB

the_plugin.md

File metadata and controls

213 lines (161 loc) · 3.3 KB

The Plugin

SharedLibraryWebpackPlugin

SharedLibraryWebpackPlugin is a class that implements webpack plugin functionality,

Options

libs

{% tabs %} {% tab title="Description" %} string | SharedLibrarySearchConfig | Array<string | SharedLibrarySearchConfig>

An option that configures the search for shared libraries and the formation of a chunk name. It can be a string or SharedLibrarySearchConfig or an array of them. {% endtab %}

{% tab title="Example" %}

new SharedLibraryWebpackPlugin({
    libs: 'lodash'
});

new SharedLibraryWebpackPlugin({
    libs: '@angular/**'
});

new SharedLibraryWebpackPlugin({
    libs: ['@angular/**', 'zone.js/dist/zone']
});

new SharedLibraryWebpackPlugin({
   libs: {name: '@angular/core', chunkName: 'ng', separator: '@'}
});

{% endtab %} {% endtabs %}

namespace

{% tabs %} {% tab title="Description" %} string

The namespace for saving exported libraries {% endtab %}

{% tab title="Example" %}

{
    namespace: "__shared_libraries__"
}

{% endtab %} {% endtabs %}

disableDefaultJsonpFunctionChange

{% tabs %} {% tab title="Description" %} boolean

By default: false

If true jsonpFunction will be replaced with a random name {% endtab %}

{% tab title="Example" %}

{
    disableDefaultJsonpFunctionChange: false
}

{% endtab %} {% endtabs %}

SharedLibrarySearchConfig

SharedLibrarySearchConfig configures the search for sharing library and the formation of a chunk name.

pattern

{% tabs %} {% tab title="Description" %} string

An option to search for libraries in a bundle. {% endtab %}

{% tab title="Example" %}

{
    pattern: "@angular/**"
}

{% endtab %} {% endtabs %}

name

{% tabs %} {% tab title="Description" %} string

A name to search for a library in a bundle. {% endtab %}

{% tab title="Example" %}

{
    name: "@angular/core"
}

{% endtab %} {% endtabs %}

chunkName

{% tabs %} {% tab title="Description" %} string

A name of a shared chunk

{% hint style="info" %} If a pattern exists chunkName is ignored {% endhint %} {% endtab %}

{% tab title="Example" %}

{
    chunkName: "ng"
}

{% endtab %} {% endtabs %}

suffix

{% tabs %} {% tab title="Description" %} string

A chunk name suffix

By default library version {major}.{minor}-{prerelease} {% endtab %}

{% tab title="Example" %}

{
    suffix: 'suffix'
}

{% endtab %} {% endtabs %}

separator

{% tabs %} {% tab title="Description" %} string

Separator for a chunk name and suffix {% endtab %}

{% tab title="Example" %}

{
    separator: "@"
}

{% endtab %} {% endtabs %}

deps

{% tabs %} {% tab title="Description" %} string[]

Libraries that the current one depends on. {% endtab %}

{% tab title="Example" %}

new SharedLibraryWebpackPlugin({
   libs: [
      '@angular/**', 
      {name: '@tinkoff/angular-ui', deps: ['@angular/core']}
   ]
})

{% endtab %} {% endtabs %}

usedExports

{% tabs %} {% tab title="Description" %} string[]

The import names to be used by another application {% endtab %}

{% tab title="Example" %}

{name: '@angular/core', usedExports: ['DomSanitizer']}

{% endtab %} {% endtabs %}