1- import InjectPlugin , { ENTRY_ORDER } from 'webpack-inject-plugin' ;
21import UglifyJs from 'uglify-js' ;
2+ import InjectPlugin , { ENTRY_ORDER } from 'webpack-inject-plugin' ;
33
4- import { FactoryConfig } from './types ' ;
4+ import { BannerPlugin , WebpackPluginInstance } from 'webpack ' ;
55import resolveDirectory from '../app/utils/resolveDirectory' ;
66import { publicPathTpl } from './constants' ;
7+ import { FactoryConfig } from './types' ;
78
89/* istanbul ignore file */
910
@@ -16,16 +17,19 @@ const defaultConf: FactoryConfig = {
1617 } ,
1718} ;
1819
20+ type FactoryResult = {
21+ client : WebpackPluginInstance [ ] ;
22+ server : WebpackPluginInstance [ ] ;
23+ } ;
24+
1925/**
2026 * This function allows you to simplify client side Webpack configuration for Apps/Parcels that work with ILC.
2127 * It's main features:
2228 * - Automatic compatibility with legacy UMD bundles. More details [available here](https://github.com/namecheap/ilc/blob/master/docs/umd_bundles_compatibility.md)
2329 * - Automatic public path configuration for Webpack bundle.
2430 * [Detailed description](https://namecheap.github.io/ilc-sdk/pages/Pages/public_path.html).
2531 */
26- export function WebpackPluginsFactory ( config : RegExp | FactoryConfig = { } ) {
27- const WrapperPlugin = require ( 'wrapper-webpack-plugin' ) ;
28-
32+ export function WebpackPluginsFactory ( config : RegExp | FactoryConfig = { } ) : FactoryResult {
2933 if ( config instanceof RegExp ) {
3034 config = {
3135 jsFilesTest : config ,
@@ -38,15 +42,21 @@ export function WebpackPluginsFactory(config: RegExp | FactoryConfig = {}) {
3842 publicPathDetection : { ...defaultConf . publicPathDetection , ...config . publicPathDetection } ,
3943 } ;
4044
41- const plugins = {
45+ const plugins : FactoryResult = {
4246 client : [
43- new WrapperPlugin ( {
47+ new BannerPlugin ( {
48+ test : conf . jsFilesTest , // only wrap output of bundle files with '.js' extension
49+ banner : '(function(define){const __ilc_script_url__ = document.currentScript.src;' ,
50+ raw : true ,
51+ } ) ,
52+ new BannerPlugin ( {
4453 test : conf . jsFilesTest , // only wrap output of bundle files with '.js' extension
45- header : '(function(define){const __ilc_script_url__ = document.currentScript.src;\n' ,
46- footer : '\n})((window.ILC && window.ILC.define) || window.define);' ,
54+ banner : '})((window.ILC && window.ILC.define) || window.define);' ,
55+ raw : true ,
56+ footer : true ,
4757 } ) ,
4858 ] ,
49- server : [ ] as any [ ] ,
59+ server : [ ] ,
5060 } ;
5161
5262 if ( conf . publicPathDetection && conf . publicPathDetection . disable ) {
0 commit comments