@teambit/webpack 0.0.844 → 0.0.847
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/html.ts +3 -2
- package/dist/config/html.js +3 -3
- package/dist/config/html.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/transformers/index.d.ts +1 -0
- package/dist/transformers/index.js +22 -0
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/inject-head.d.ts +14 -0
- package/dist/transformers/inject-head.js +33 -0
- package/dist/transformers/inject-head.js.map +1 -0
- package/package-tar/teambit-webpack-0.0.847.tgz +0 -0
- package/package.json +11 -10
- package/{preview-1662281577904.js → preview-1662694416892.js} +2 -2
- package/transformers/index.ts +1 -0
- package/transformers/inject-head.ts +22 -0
- package/package-tar/teambit-webpack-0.0.844.tgz +0 -0
package/config/html.ts
CHANGED
|
@@ -11,8 +11,7 @@ export function html(title: string) {
|
|
|
11
11
|
// Allow to use react dev-tools inside the examples
|
|
12
12
|
try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}
|
|
13
13
|
</script>
|
|
14
|
-
|
|
15
|
-
<style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
|
14
|
+
<style> body { margin: 0; } </style>
|
|
16
15
|
</head>
|
|
17
16
|
<body>
|
|
18
17
|
<div id="root"></div>
|
|
@@ -20,3 +19,5 @@ export function html(title: string) {
|
|
|
20
19
|
</html>
|
|
21
20
|
`;
|
|
22
21
|
}
|
|
22
|
+
// <!-- minimal css resets -->
|
|
23
|
+
// <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
package/dist/config/html.js
CHANGED
|
@@ -18,14 +18,14 @@ function html(title) {
|
|
|
18
18
|
// Allow to use react dev-tools inside the examples
|
|
19
19
|
try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}
|
|
20
20
|
</script>
|
|
21
|
-
|
|
22
|
-
<style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
|
21
|
+
<style> body { margin: 0; } </style>
|
|
23
22
|
</head>
|
|
24
23
|
<body>
|
|
25
24
|
<div id="root"></div>
|
|
26
25
|
</body>
|
|
27
26
|
</html>
|
|
28
27
|
`;
|
|
29
|
-
}
|
|
28
|
+
} // <!-- minimal css resets -->
|
|
29
|
+
// <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>
|
|
30
30
|
|
|
31
31
|
//# sourceMappingURL=html.js.map
|
package/dist/config/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["html","title"],"sources":["html.ts"],"sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return () => `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n
|
|
1
|
+
{"version":3,"names":["html","title"],"sources":["html.ts"],"sourcesContent":["/** html template for Previews (docs, compositions, etc) */\nexport function html(title: string) {\n return () => `\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>${title}</title>\n <script>\n // Allow to use react dev-tools inside the examples\n try { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; } catch {}\n </script>\n <style> body { margin: 0; } </style>\n </head>\n <body>\n <div id=\"root\"></div>\n </body>\n </html>\n `;\n}\n// <!-- minimal css resets -->\n// <style> html { height: 100%; } body { margin: 0; height: 100%; } #root { height: 100%; } </style>"],"mappings":";;;;;;;AAAA;AACO,SAASA,IAAT,CAAcC,KAAd,EAA6B;EAClC,OAAO,MAAO;AAChB;AACA;AACA;AACA;AACA;AACA,eAAeA,KAAM;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAjBE;AAkBD,C,CACD;AACA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,4 +11,4 @@ export { WebpackBitReporterPlugin } from './plugins/webpack-bit-reporter-plugin'
|
|
|
11
11
|
export { fallbacks } from './config/webpack-fallbacks';
|
|
12
12
|
export { fallbacksAliases } from './config/webpack-fallbacks-aliases';
|
|
13
13
|
export { fallbacksProvidePluginConfig } from './config/webpack-fallbacks-provide-plugin-config';
|
|
14
|
-
export { GenerateBodyInjectionTransformer, BodyInjectionOptions, generateAddAliasesFromPeersTransformer, generateExposePeersTransformer, generateExternalsTransformer, } from './transformers';
|
|
14
|
+
export { GenerateBodyInjectionTransformer, BodyInjectionOptions, generateAddAliasesFromPeersTransformer, generateExposePeersTransformer, generateExternalsTransformer, GenerateHeadInjectionTransformer, HeadInjectionOptions } from './transformers';
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,9 @@ var _exportNames = {
|
|
|
18
18
|
BodyInjectionOptions: true,
|
|
19
19
|
generateAddAliasesFromPeersTransformer: true,
|
|
20
20
|
generateExposePeersTransformer: true,
|
|
21
|
-
generateExternalsTransformer: true
|
|
21
|
+
generateExternalsTransformer: true,
|
|
22
|
+
GenerateHeadInjectionTransformer: true,
|
|
23
|
+
HeadInjectionOptions: true
|
|
22
24
|
};
|
|
23
25
|
Object.defineProperty(exports, "BodyInjectionOptions", {
|
|
24
26
|
enumerable: true,
|
|
@@ -38,6 +40,18 @@ Object.defineProperty(exports, "GenerateBodyInjectionTransformer", {
|
|
|
38
40
|
return _transformers().GenerateBodyInjectionTransformer;
|
|
39
41
|
}
|
|
40
42
|
});
|
|
43
|
+
Object.defineProperty(exports, "GenerateHeadInjectionTransformer", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _transformers().GenerateHeadInjectionTransformer;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "HeadInjectionOptions", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return _transformers().HeadInjectionOptions;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
41
55
|
Object.defineProperty(exports, "WebpackAspect", {
|
|
42
56
|
enumerable: true,
|
|
43
57
|
get: function () {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type {\n WebpackMain,\n WebpackConfigTransformer,\n WebpackConfigTransformContext,\n WebpackConfigDevServerTransformContext,\n GlobalWebpackConfigTransformContext,\n WebpackConfigDevServerTransformer,\n} from './webpack.main.runtime';\nexport { runTransformersWithContext } from './webpack.main.runtime';\nexport { WebpackAspect } from './webpack.aspect';\nexport { WebpackDevServer } from './webpack.dev-server';\nexport { WebpackBundler } from './webpack.bundler';\nexport type { WebpackConfigWithDevServer } from './webpack.dev-server';\nexport * from './events';\nexport { Configuration } from 'webpack';\nexport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\nexport { WebpackBitReporterPlugin } from './plugins/webpack-bit-reporter-plugin';\nexport { fallbacks } from './config/webpack-fallbacks';\nexport { fallbacksAliases } from './config/webpack-fallbacks-aliases';\nexport { fallbacksProvidePluginConfig } from './config/webpack-fallbacks-provide-plugin-config';\nexport {\n GenerateBodyInjectionTransformer,\n BodyInjectionOptions,\n generateAddAliasesFromPeersTransformer,\n generateExposePeersTransformer,\n generateExternalsTransformer,\n} from './transformers';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type {\n WebpackMain,\n WebpackConfigTransformer,\n WebpackConfigTransformContext,\n WebpackConfigDevServerTransformContext,\n GlobalWebpackConfigTransformContext,\n WebpackConfigDevServerTransformer,\n} from './webpack.main.runtime';\nexport { runTransformersWithContext } from './webpack.main.runtime';\nexport { WebpackAspect } from './webpack.aspect';\nexport { WebpackDevServer } from './webpack.dev-server';\nexport { WebpackBundler } from './webpack.bundler';\nexport type { WebpackConfigWithDevServer } from './webpack.dev-server';\nexport * from './events';\nexport { Configuration } from 'webpack';\nexport { WebpackConfigMutator } from '@teambit/webpack.modules.config-mutator';\nexport { WebpackBitReporterPlugin } from './plugins/webpack-bit-reporter-plugin';\nexport { fallbacks } from './config/webpack-fallbacks';\nexport { fallbacksAliases } from './config/webpack-fallbacks-aliases';\nexport { fallbacksProvidePluginConfig } from './config/webpack-fallbacks-provide-plugin-config';\nexport {\n GenerateBodyInjectionTransformer,\n BodyInjectionOptions,\n generateAddAliasesFromPeersTransformer,\n generateExposePeersTransformer,\n generateExternalsTransformer,\n GenerateHeadInjectionTransformer,\n HeadInjectionOptions\n} from './transformers';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export { GenerateBodyInjectionTransformer, BodyInjectionOptions } from './inject-body';
|
|
2
|
+
export { GenerateHeadInjectionTransformer, HeadInjectionOptions } from './inject-head';
|
|
2
3
|
export { generateAddAliasesFromPeersTransformer, generateExposePeersTransformer, generateExternalsTransformer, } from './transformers';
|
|
@@ -15,6 +15,18 @@ Object.defineProperty(exports, "GenerateBodyInjectionTransformer", {
|
|
|
15
15
|
return _injectBody().GenerateBodyInjectionTransformer;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "GenerateHeadInjectionTransformer", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _injectHead().GenerateHeadInjectionTransformer;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "HeadInjectionOptions", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _injectHead().HeadInjectionOptions;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
18
30
|
Object.defineProperty(exports, "generateAddAliasesFromPeersTransformer", {
|
|
19
31
|
enumerable: true,
|
|
20
32
|
get: function () {
|
|
@@ -44,6 +56,16 @@ function _injectBody() {
|
|
|
44
56
|
return data;
|
|
45
57
|
}
|
|
46
58
|
|
|
59
|
+
function _injectHead() {
|
|
60
|
+
const data = require("./inject-head");
|
|
61
|
+
|
|
62
|
+
_injectHead = function () {
|
|
63
|
+
return data;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return data;
|
|
67
|
+
}
|
|
68
|
+
|
|
47
69
|
function _transformers() {
|
|
48
70
|
const data = require("./transformers");
|
|
49
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { GenerateBodyInjectionTransformer, BodyInjectionOptions } from './inject-body';\nexport {\n generateAddAliasesFromPeersTransformer,\n generateExposePeersTransformer,\n generateExternalsTransformer,\n} from './transformers';\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { GenerateBodyInjectionTransformer, BodyInjectionOptions } from './inject-body';\nexport { GenerateHeadInjectionTransformer, HeadInjectionOptions } from './inject-head';\nexport {\n generateAddAliasesFromPeersTransformer,\n generateExposePeersTransformer,\n generateExternalsTransformer,\n} from './transformers';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { WebpackConfigTransformer } from '@teambit/webpack';
|
|
2
|
+
export declare type HeadInjectionOptions = {
|
|
3
|
+
content: string;
|
|
4
|
+
position?: 'start' | 'end';
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* A transformer that allow you to inject content into your html head
|
|
8
|
+
* We expose it from here, as it uses the inject-head-webpack-plugin which register to the html plugin hooks
|
|
9
|
+
* which means it depends on the fact that it has the same html plugin instance
|
|
10
|
+
* since, the html plugin is configured via the webpack aspect, expose it from here ensure the same instance
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function GenerateHeadInjectionTransformer(options: HeadInjectionOptions): WebpackConfigTransformer;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.GenerateHeadInjectionTransformer = GenerateHeadInjectionTransformer;
|
|
7
|
+
|
|
8
|
+
function _webpackPlugins() {
|
|
9
|
+
const data = require("@teambit/webpack.plugins.inject-head-webpack-plugin");
|
|
10
|
+
|
|
11
|
+
_webpackPlugins = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A transformer that allow you to inject content into your html head
|
|
20
|
+
* We expose it from here, as it uses the inject-head-webpack-plugin which register to the html plugin hooks
|
|
21
|
+
* which means it depends on the fact that it has the same html plugin instance
|
|
22
|
+
* since, the html plugin is configured via the webpack aspect, expose it from here ensure the same instance
|
|
23
|
+
* @param options
|
|
24
|
+
* @returns
|
|
25
|
+
*/
|
|
26
|
+
function GenerateHeadInjectionTransformer(options) {
|
|
27
|
+
return config => {
|
|
28
|
+
const plugin = new (_webpackPlugins().InjectHeadPlugin)(options);
|
|
29
|
+
return config.addPlugin(plugin);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=inject-head.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GenerateHeadInjectionTransformer","options","config","plugin","InjectHeadPlugin","addPlugin"],"sources":["inject-head.ts"],"sourcesContent":["import {InjectHeadPlugin} from '@teambit/webpack.plugins.inject-head-webpack-plugin';\nimport type { WebpackConfigTransformer } from '@teambit/webpack';\n\nexport type HeadInjectionOptions = {\n content: string;\n position?: 'start' | 'end';\n};\n\n/**\n * A transformer that allow you to inject content into your html head\n * We expose it from here, as it uses the inject-head-webpack-plugin which register to the html plugin hooks\n * which means it depends on the fact that it has the same html plugin instance\n * since, the html plugin is configured via the webpack aspect, expose it from here ensure the same instance\n * @param options\n * @returns\n */\nexport function GenerateHeadInjectionTransformer(options: HeadInjectionOptions): WebpackConfigTransformer {\n return (config) => {\n const plugin = new InjectHeadPlugin(options);\n return config.addPlugin(plugin);\n };\n}\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gCAAT,CAA0CC,OAA1C,EAAmG;EACxG,OAAQC,MAAD,IAAY;IACjB,MAAMC,MAAM,GAAG,KAAIC,kCAAJ,EAAqBH,OAArB,CAAf;IACA,OAAOC,MAAM,CAACG,SAAP,CAAiBF,MAAjB,CAAP;EACD,CAHD;AAID"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.847",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/webpack/webpack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.webpack",
|
|
8
8
|
"name": "webpack",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.847"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"webpack": "5.51.1",
|
|
@@ -45,16 +45,17 @@
|
|
|
45
45
|
"assert": "2.0.0",
|
|
46
46
|
"@babel/runtime": "7.12.18",
|
|
47
47
|
"core-js": "^3.0.0",
|
|
48
|
-
"@teambit/harmony": "0.3.3",
|
|
49
48
|
"@teambit/webpack.modules.config-mutator": "0.0.147",
|
|
49
|
+
"@teambit/harmony": "0.3.3",
|
|
50
50
|
"@teambit/bit-error": "0.0.400",
|
|
51
|
-
"@teambit/bundler": "0.0.
|
|
52
|
-
"@teambit/logger": "0.0.
|
|
53
|
-
"@teambit/cli": "0.0.
|
|
54
|
-
"@teambit/pubsub": "0.0.
|
|
55
|
-
"@teambit/workspace": "0.0.
|
|
51
|
+
"@teambit/bundler": "0.0.847",
|
|
52
|
+
"@teambit/logger": "0.0.658",
|
|
53
|
+
"@teambit/cli": "0.0.565",
|
|
54
|
+
"@teambit/pubsub": "0.0.847",
|
|
55
|
+
"@teambit/workspace": "0.0.847",
|
|
56
56
|
"@teambit/webpack.modules.generate-expose-loaders": "0.0.9",
|
|
57
|
-
"@teambit/webpack.modules.generate-externals": "0.0.10"
|
|
57
|
+
"@teambit/webpack.modules.generate-externals": "0.0.10",
|
|
58
|
+
"@teambit/webpack.plugins.inject-head-webpack-plugin": "0.0.1"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
61
|
"@types/webpack": "5.28.0",
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"@types/node": "12.20.4"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
|
-
"@teambit/legacy": "1.0.
|
|
73
|
+
"@teambit/legacy": "1.0.346",
|
|
73
74
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
74
75
|
"react": "^16.8.0 || ^17.0.0"
|
|
75
76
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@0.0.847/dist/webpack.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.webpack_webpack@0.0.847/dist/webpack.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/transformers/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {InjectHeadPlugin} from '@teambit/webpack.plugins.inject-head-webpack-plugin';
|
|
2
|
+
import type { WebpackConfigTransformer } from '@teambit/webpack';
|
|
3
|
+
|
|
4
|
+
export type HeadInjectionOptions = {
|
|
5
|
+
content: string;
|
|
6
|
+
position?: 'start' | 'end';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A transformer that allow you to inject content into your html head
|
|
11
|
+
* We expose it from here, as it uses the inject-head-webpack-plugin which register to the html plugin hooks
|
|
12
|
+
* which means it depends on the fact that it has the same html plugin instance
|
|
13
|
+
* since, the html plugin is configured via the webpack aspect, expose it from here ensure the same instance
|
|
14
|
+
* @param options
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export function GenerateHeadInjectionTransformer(options: HeadInjectionOptions): WebpackConfigTransformer {
|
|
18
|
+
return (config) => {
|
|
19
|
+
const plugin = new InjectHeadPlugin(options);
|
|
20
|
+
return config.addPlugin(plugin);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
Binary file
|