@commercetools-frontend/mc-html-template 0.0.0-CRAFT-1791-20251006162610
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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/commercetools-frontend-mc-html-template.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-mc-html-template.cjs.dev.js +201 -0
- package/dist/commercetools-frontend-mc-html-template.cjs.js +7 -0
- package/dist/commercetools-frontend-mc-html-template.cjs.prod.js +201 -0
- package/dist/commercetools-frontend-mc-html-template.esm.js +173 -0
- package/dist/declarations/src/compile-html.d.ts +8 -0
- package/dist/declarations/src/generate-template.d.ts +6 -0
- package/dist/declarations/src/index.d.ts +4 -0
- package/dist/declarations/src/process-headers.d.ts +4 -0
- package/dist/declarations/src/replace-html-placeholders.d.ts +8 -0
- package/dist/declarations/src/webpack-html-template.d.ts +3 -0
- package/dist/generate-template-13b74c05.cjs.dev.js +15 -0
- package/dist/generate-template-31dee161.esm.js +13 -0
- package/dist/generate-template-794a5676.cjs.prod.js +15 -0
- package/package.json +56 -0
- package/webpack-html-template/dist/commercetools-frontend-mc-html-template-webpack-html-template.cjs.d.ts +3 -0
- package/webpack-html-template/dist/commercetools-frontend-mc-html-template-webpack-html-template.cjs.dev.js +42 -0
- package/webpack-html-template/dist/commercetools-frontend-mc-html-template-webpack-html-template.cjs.js +7 -0
- package/webpack-html-template/dist/commercetools-frontend-mc-html-template-webpack-html-template.cjs.prod.js +42 -0
- package/webpack-html-template/dist/commercetools-frontend-mc-html-template-webpack-html-template.esm.js +31 -0
- package/webpack-html-template/package.json +4 -0
- package/webpack.js +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# @commercetools-frontend/mc-html-template
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@commercetools-frontend/mc-html-template"><img src="https://badgen.net/npm/v/@commercetools-frontend/mc-html-template" alt="Latest release (latest dist-tag)" /></a> <a href="https://www.npmjs.com/package/@commercetools-frontend/mc-html-template"><img src="https://badgen.net/npm/v/@commercetools-frontend/mc-html-template/next" alt="Latest release (next dist-tag)" /></a> <a href="https://bundlephobia.com/result?p=@commercetools-frontend/mc-html-template"><img src="https://badgen.net/bundlephobia/minzip/@commercetools-frontend/mc-html-template" alt="Minified + GZipped size" /></a> <a href="https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE"><img src="https://badgen.net/github/license/commercetools/merchant-center-application-kit" alt="GitHub license" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
This package contains utils and scripts related to the `index.html` for a Merchant Center customization.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm install --save @commercetools-frontend/mc-html-template
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
### `generateTemplate`
|
|
18
|
+
|
|
19
|
+
This method will return the template HTML document with the provided CSS/JS scripts injected.
|
|
20
|
+
|
|
21
|
+
> NOTE that the HTML document will still have the **placeholders** (see `replaceHtmlPlaceholders`)
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
type TGenerateTemplateOptions = {
|
|
25
|
+
cssImports?: string[];
|
|
26
|
+
scriptImports?: string[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function generateTemplate({
|
|
30
|
+
cssImports = [],
|
|
31
|
+
scriptImports = [],
|
|
32
|
+
}: TGenerateTemplateOptions);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### `replaceHtmlPlaceholders`
|
|
36
|
+
|
|
37
|
+
This method will replace the **placeholders** defined in the HTML document based on the application config.
|
|
38
|
+
|
|
39
|
+
This method should be used as the final step to get the fully compiled `index.html`.
|
|
40
|
+
|
|
41
|
+
At the moment we define the following placeholders:
|
|
42
|
+
|
|
43
|
+
- `__CDN_URL__`: the `cdnUrl` value defined in the application config
|
|
44
|
+
- `__MC_API_URL__`: the `mcApiUrl` value defined in the application config
|
|
45
|
+
- `__LOADING_SCREEN_CSS__`: (_defined internally_) the CSS for the loading animation in case the page takes longer to load
|
|
46
|
+
- `__LOADING_SCREEN_JS__`: (_defined internally_) the JS for the loading animation in case the page takes longer to load
|
|
47
|
+
- `__APP_ENVIRONMENT__`: the sanitized application config environment, which will be available at the global variable `window.app`
|
|
48
|
+
- `__CSP__`: the generated `Content-Security-Policy` directives, defined as an HTML meta tag
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
type TReplaceHtmlPlaceholdersOptions = {
|
|
52
|
+
env: ApplicationRuntimeConfig['env'];
|
|
53
|
+
headers: Record<string, string | undefined>;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function replaceHtmlPlaceholders(
|
|
57
|
+
indexHtmlContent: string,
|
|
58
|
+
options: TReplaceHtmlPlaceholdersOptions
|
|
59
|
+
): string;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### `compileHtml`
|
|
63
|
+
|
|
64
|
+
This method will compile the template HTML document.
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
type TCompileHtmlResult = {
|
|
68
|
+
env: ApplicationRuntimeConfig['env'];
|
|
69
|
+
headers: Record<string, string | undefined>;
|
|
70
|
+
indexHtmlContent: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
async function compileHtml(
|
|
74
|
+
indexHtmlTemplatePath: string
|
|
75
|
+
): Promise<TCompileHtmlResult>;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `processHeaders`
|
|
79
|
+
|
|
80
|
+
This method will return the security headers to be used on the server response, serving the `index.html`.
|
|
81
|
+
|
|
82
|
+
The `applicationConfig.env` is the processed application environment that would be injected as the `window.app`.
|
|
83
|
+
The `applicationConfig.headers` is the processed application headers provided by the user.
|
|
84
|
+
|
|
85
|
+
The return value of the `processHeaders` function contains the following ready-to-use HTTP headers:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"Strict-Transport-Security": "max-age=31536000",
|
|
90
|
+
"X-XSS-Protection": "1; mode=block",
|
|
91
|
+
"X-Content-Type-Options": "nosniff",
|
|
92
|
+
"X-Frame-Options": "SAMEORIGIN",
|
|
93
|
+
"Content-Security-Policy": "...",
|
|
94
|
+
"Feature-Policies": "..."
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
function processHeaders(
|
|
100
|
+
applicationConfig: ApplicationRuntimeConfig
|
|
101
|
+
): Record<string, string | undefined>;
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Bundler entry points
|
|
105
|
+
|
|
106
|
+
The package exposes some special entry points used by specific bundlers to use the HTML template.
|
|
107
|
+
|
|
108
|
+
#### Webpack
|
|
109
|
+
|
|
110
|
+
If you use Webpack with the `HtmlWebpackPlugin`, you can pass the `webpack` entry point that will map the Webpack template params to our generic `generateTemplate` method.
|
|
111
|
+
|
|
112
|
+
```js
|
|
113
|
+
new HtmlWebpackPlugin({
|
|
114
|
+
template: require.resolve(
|
|
115
|
+
'@commercetools-frontend/mc-html-template/webpack'
|
|
116
|
+
),
|
|
117
|
+
// ...
|
|
118
|
+
}),
|
|
119
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1tYy1odG1sLXRlbXBsYXRlLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
7
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
8
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
9
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
10
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
11
|
+
var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
12
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
13
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
14
|
+
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
15
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
16
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
18
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
19
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
20
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
21
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
22
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
23
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
24
|
+
var constants = require('@commercetools-frontend/constants');
|
|
25
|
+
var crypto = require('crypto');
|
|
26
|
+
var serialize = require('serialize-javascript');
|
|
27
|
+
var generateTemplate = require('./generate-template-13b74c05.cjs.dev.js');
|
|
28
|
+
|
|
29
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
30
|
+
|
|
31
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
32
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
33
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
34
|
+
var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
|
|
35
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
36
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
37
|
+
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
38
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
39
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
40
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
41
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
42
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
43
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
44
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
45
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
46
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
47
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
48
|
+
var serialize__default = /*#__PURE__*/_interopDefault(serialize);
|
|
49
|
+
|
|
50
|
+
function createAssetHash(content) {
|
|
51
|
+
const sha256Hash = crypto__default["default"].createHash('sha256').update(content).digest('base64');
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* NOTE:
|
|
55
|
+
* We prefix the hash function type as the browser
|
|
56
|
+
* needs it when validating the contents of a script against
|
|
57
|
+
* CSP headers sent.
|
|
58
|
+
* For more information head to: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Sources
|
|
59
|
+
*/
|
|
60
|
+
return `sha256-${sha256Hash}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const sanitizeAppEnvironment = env => serialize__default["default"](env, {
|
|
64
|
+
isJSON: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
68
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
69
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
70
|
+
const htmlScripts$1 = {
|
|
71
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
72
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
73
|
+
};
|
|
74
|
+
const toArray = value => _Array$isArray__default["default"](value) ? value : [value];
|
|
75
|
+
const parseCSPDirectives = function () {
|
|
76
|
+
var _context2;
|
|
77
|
+
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
78
|
+
directives[_key] = arguments[_key];
|
|
79
|
+
}
|
|
80
|
+
const mergedDirectives = _reduceInstanceProperty__default["default"](directives).call(directives, (mergedDirectives, directive) => {
|
|
81
|
+
var _context;
|
|
82
|
+
return _Object$assign__default["default"](mergedDirectives, _reduceInstanceProperty__default["default"](_context = _Object$keys__default["default"](directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
83
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
84
|
+
return _Object$assign__default["default"](mergedDirectiveValues, {
|
|
85
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
86
|
+
});
|
|
87
|
+
}, {}));
|
|
88
|
+
}, {});
|
|
89
|
+
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](mergedDirectives)).call(_context2, _ref => {
|
|
90
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
91
|
+
directive = _ref2[0],
|
|
92
|
+
value = _ref2[1];
|
|
93
|
+
return `${directive} ${_Array$isArray__default["default"](value) ? value.join(' ') : value}`;
|
|
94
|
+
}).join('; ');
|
|
95
|
+
};
|
|
96
|
+
const parsePermissionsPolicyDirectives = (defaultValue, customDirectives) => {
|
|
97
|
+
var _context3;
|
|
98
|
+
const mergedDirectives = _mapInstanceProperty__default["default"](_context3 = defaultValue.split(',')).call(_context3, directive => {
|
|
99
|
+
const _directive$trim$split = _trimInstanceProperty__default["default"](directive).call(directive).split('='),
|
|
100
|
+
_directive$trim$split2 = _slicedToArray(_directive$trim$split, 2),
|
|
101
|
+
directiveName = _directive$trim$split2[0],
|
|
102
|
+
directiveValue = _directive$trim$split2[1];
|
|
103
|
+
const overrideDirectiveValue = customDirectives[directiveName];
|
|
104
|
+
if (overrideDirectiveValue) {
|
|
105
|
+
return [directiveName, overrideDirectiveValue].join('=');
|
|
106
|
+
}
|
|
107
|
+
return [directiveName, directiveValue].join('=');
|
|
108
|
+
});
|
|
109
|
+
return mergedDirectives.join(', ');
|
|
110
|
+
};
|
|
111
|
+
const processHeaders = applicationConfig => {
|
|
112
|
+
var _context4, _context5, _context6;
|
|
113
|
+
const isMcDevEnv = applicationConfig.env.env === 'development';
|
|
114
|
+
|
|
115
|
+
// List hashes for injected inline scripts.
|
|
116
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
|
|
117
|
+
const htmlScriptsHashes = [createAssetHash(htmlScripts$1.loadingScreen), createAssetHash(`window.app = ${sanitizeAppEnvironment(applicationConfig.env)};`), createAssetHash(htmlScripts$1.publicPath)];
|
|
118
|
+
|
|
119
|
+
// // List hashes for injected inline styles.
|
|
120
|
+
// // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
|
|
121
|
+
// const htmlStylesHashes = [createAssetHash(htmlStyles.loadingScreen)];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Content Security Policy (CSP)
|
|
125
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
126
|
+
*/
|
|
127
|
+
const defaultCSPDirectives = _Object$assign__default["default"]({
|
|
128
|
+
'default-src': "'none'",
|
|
129
|
+
'script-src': _concatInstanceProperty__default["default"](_context4 = ["'self'"]).call(_context4, isMcDevEnv ?
|
|
130
|
+
// Allow webpack to load source maps on runtime when errors occur
|
|
131
|
+
// using script tags
|
|
132
|
+
['localhost:*', "'unsafe-inline'"] : _mapInstanceProperty__default["default"](htmlScriptsHashes).call(htmlScriptsHashes, assetHash => `'${assetHash}'`)),
|
|
133
|
+
'connect-src': _concatInstanceProperty__default["default"](_context5 = ["'self'", 'app.launchdarkly.com', 'clientstream.launchdarkly.com', 'events.launchdarkly.com', 'app.getsentry.com',
|
|
134
|
+
// Match all attempts to load from any subdomain of `sentry.io`
|
|
135
|
+
'*.sentry.io']).call(_context5, isMcDevEnv ? ['ws:', 'localhost:8080', 'webpack-internal:'] : []),
|
|
136
|
+
'img-src': ['*', 'data:'],
|
|
137
|
+
'style-src': _concatInstanceProperty__default["default"](_context6 = ["'self'", 'fonts.googleapis.com', 'data:']).call(_context6,
|
|
138
|
+
// TODO: investigate what needs to be done to avoid unsafe-inline styles
|
|
139
|
+
// https://github.com/commercetools/merchant-center-frontend/pull/5223#discussion_r210367636
|
|
140
|
+
["'unsafe-inline'"]
|
|
141
|
+
// TODO: enable this once we can avoid unsafe-inline
|
|
142
|
+
// htmlStylesHashes.map(assetHash => `'${assetHash}'`)
|
|
143
|
+
),
|
|
144
|
+
'font-src': ["'self'", 'fonts.gstatic.com', 'data:'],
|
|
145
|
+
// Required for Custom Views
|
|
146
|
+
'frame-src': ["'self'"]
|
|
147
|
+
}, isMcDevEnv ? {
|
|
148
|
+
// NOTE: use this instead of `upgrade-insecure-requests` for local
|
|
149
|
+
// development to avoid `http://localhost` requests to be redirected
|
|
150
|
+
// to https.
|
|
151
|
+
'block-all-mixed-content': ''
|
|
152
|
+
} : {
|
|
153
|
+
// NOTE: prefer this over `block-all-mixed-content`.
|
|
154
|
+
// https://youtu.be/j-0Bj40juMI?t=11m47s
|
|
155
|
+
'upgrade-insecure-requests': ''
|
|
156
|
+
}
|
|
157
|
+
// NOTE: we might want to define further policies in the future, for example
|
|
158
|
+
// - `require-sri-for style script` (at the moment not possible because
|
|
159
|
+
// Intercom scripts are apparently not meant for this)
|
|
160
|
+
);
|
|
161
|
+
return _objectSpread(_objectSpread({}, constants.HTTP_SECURITY_HEADERS), {}, {
|
|
162
|
+
// The `Content-Security-Policy` header is always generated
|
|
163
|
+
// based on the Merchant Center customization config.
|
|
164
|
+
[constants.HTTP_SECURITY_HEADER_KEYS['Content-Security-Policy']]: parseCSPDirectives(defaultCSPDirectives, applicationConfig.headers?.csp ?? {})
|
|
165
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
166
|
+
[constants.HTTP_SECURITY_HEADER_KEYS['Permissions-Policy']]: parsePermissionsPolicyDirectives(constants.HTTP_SECURITY_HEADERS['Permissions-Policy'], applicationConfig.headers.permissionsPolicies ?? {})
|
|
167
|
+
} : {});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
171
|
+
const htmlScripts = {
|
|
172
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
173
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
174
|
+
}; // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
175
|
+
const htmlStyles = {
|
|
176
|
+
"loadingScreen": ".loading-screen{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;width:100vw}.loading-screen--hidden{display:none}.loading-screen>*+*{margin:24px 0 0}.loading-spinner{width:32px;height:32px}.long-loading-notice{color:#999;font-family:'Open Sans',sans-serif;font-size:12px}.long-loading-notice--hidden{visibility:hidden}.loading-spinner-circle{fill:#213c45;opacity:.2}@keyframes loading-spinner-animation{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.loading-spinner-pointer{transform-origin:20px 20px 0;animation:loading-spinner-animation .5s infinite linear}"
|
|
177
|
+
};
|
|
178
|
+
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
179
|
+
const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.replace(new RegExp('__CSP__', 'g'), options.headers?.['Content-Security-Policy'] ?? '').replace(new RegExp('__CDN_URL__', 'g'), options.env.cdnUrl ?
|
|
180
|
+
// Ensure there is a trailing slash
|
|
181
|
+
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
182
|
+
|
|
183
|
+
async function compileHtml(indexHtmlTemplatePath) {
|
|
184
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
185
|
+
const compiledHeaders = processHeaders(applicationConfig$1);
|
|
186
|
+
const indexHtmlTemplateContent = fs__default["default"].readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
187
|
+
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
|
188
|
+
env: applicationConfig$1.env,
|
|
189
|
+
headers: compiledHeaders
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
env: applicationConfig$1.env,
|
|
193
|
+
headers: compiledHeaders,
|
|
194
|
+
indexHtmlContent
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
exports.generateTemplate = generateTemplate.generateTemplate;
|
|
199
|
+
exports.compileHtml = compileHtml;
|
|
200
|
+
exports.processHeaders = processHeaders;
|
|
201
|
+
exports.replaceHtmlPlaceholders = replaceHtmlPlaceholders;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var fs = require('fs');
|
|
6
|
+
var applicationConfig = require('@commercetools-frontend/application-config');
|
|
7
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
8
|
+
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
9
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
10
|
+
var _reduceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/reduce');
|
|
11
|
+
var _Object$assign = require('@babel/runtime-corejs3/core-js-stable/object/assign');
|
|
12
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
13
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
14
|
+
var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
|
|
15
|
+
var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
|
|
16
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
17
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
18
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
19
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
20
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
21
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
22
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
23
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
24
|
+
var constants = require('@commercetools-frontend/constants');
|
|
25
|
+
var crypto = require('crypto');
|
|
26
|
+
var serialize = require('serialize-javascript');
|
|
27
|
+
var generateTemplate = require('./generate-template-794a5676.cjs.prod.js');
|
|
28
|
+
|
|
29
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
30
|
+
|
|
31
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
32
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
33
|
+
var _reduceInstanceProperty__default = /*#__PURE__*/_interopDefault(_reduceInstanceProperty);
|
|
34
|
+
var _Object$assign__default = /*#__PURE__*/_interopDefault(_Object$assign);
|
|
35
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
36
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
37
|
+
var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
|
|
38
|
+
var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
|
|
39
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
40
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
41
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
42
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
43
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
44
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
45
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
46
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
47
|
+
var crypto__default = /*#__PURE__*/_interopDefault(crypto);
|
|
48
|
+
var serialize__default = /*#__PURE__*/_interopDefault(serialize);
|
|
49
|
+
|
|
50
|
+
function createAssetHash(content) {
|
|
51
|
+
const sha256Hash = crypto__default["default"].createHash('sha256').update(content).digest('base64');
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* NOTE:
|
|
55
|
+
* We prefix the hash function type as the browser
|
|
56
|
+
* needs it when validating the contents of a script against
|
|
57
|
+
* CSP headers sent.
|
|
58
|
+
* For more information head to: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Sources
|
|
59
|
+
*/
|
|
60
|
+
return `sha256-${sha256Hash}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const sanitizeAppEnvironment = env => serialize__default["default"](env, {
|
|
64
|
+
isJSON: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
68
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
69
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
70
|
+
const htmlScripts$1 = {
|
|
71
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
72
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
73
|
+
};
|
|
74
|
+
const toArray = value => _Array$isArray__default["default"](value) ? value : [value];
|
|
75
|
+
const parseCSPDirectives = function () {
|
|
76
|
+
var _context2;
|
|
77
|
+
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
78
|
+
directives[_key] = arguments[_key];
|
|
79
|
+
}
|
|
80
|
+
const mergedDirectives = _reduceInstanceProperty__default["default"](directives).call(directives, (mergedDirectives, directive) => {
|
|
81
|
+
var _context;
|
|
82
|
+
return _Object$assign__default["default"](mergedDirectives, _reduceInstanceProperty__default["default"](_context = _Object$keys__default["default"](directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
83
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
84
|
+
return _Object$assign__default["default"](mergedDirectiveValues, {
|
|
85
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
86
|
+
});
|
|
87
|
+
}, {}));
|
|
88
|
+
}, {});
|
|
89
|
+
return _mapInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](mergedDirectives)).call(_context2, _ref => {
|
|
90
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
91
|
+
directive = _ref2[0],
|
|
92
|
+
value = _ref2[1];
|
|
93
|
+
return `${directive} ${_Array$isArray__default["default"](value) ? value.join(' ') : value}`;
|
|
94
|
+
}).join('; ');
|
|
95
|
+
};
|
|
96
|
+
const parsePermissionsPolicyDirectives = (defaultValue, customDirectives) => {
|
|
97
|
+
var _context3;
|
|
98
|
+
const mergedDirectives = _mapInstanceProperty__default["default"](_context3 = defaultValue.split(',')).call(_context3, directive => {
|
|
99
|
+
const _directive$trim$split = _trimInstanceProperty__default["default"](directive).call(directive).split('='),
|
|
100
|
+
_directive$trim$split2 = _slicedToArray(_directive$trim$split, 2),
|
|
101
|
+
directiveName = _directive$trim$split2[0],
|
|
102
|
+
directiveValue = _directive$trim$split2[1];
|
|
103
|
+
const overrideDirectiveValue = customDirectives[directiveName];
|
|
104
|
+
if (overrideDirectiveValue) {
|
|
105
|
+
return [directiveName, overrideDirectiveValue].join('=');
|
|
106
|
+
}
|
|
107
|
+
return [directiveName, directiveValue].join('=');
|
|
108
|
+
});
|
|
109
|
+
return mergedDirectives.join(', ');
|
|
110
|
+
};
|
|
111
|
+
const processHeaders = applicationConfig => {
|
|
112
|
+
var _context4, _context5, _context6;
|
|
113
|
+
const isMcDevEnv = applicationConfig.env.env === 'development';
|
|
114
|
+
|
|
115
|
+
// List hashes for injected inline scripts.
|
|
116
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
|
|
117
|
+
const htmlScriptsHashes = [createAssetHash(htmlScripts$1.loadingScreen), createAssetHash(`window.app = ${sanitizeAppEnvironment(applicationConfig.env)};`), createAssetHash(htmlScripts$1.publicPath)];
|
|
118
|
+
|
|
119
|
+
// // List hashes for injected inline styles.
|
|
120
|
+
// // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
|
|
121
|
+
// const htmlStylesHashes = [createAssetHash(htmlStyles.loadingScreen)];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Content Security Policy (CSP)
|
|
125
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
126
|
+
*/
|
|
127
|
+
const defaultCSPDirectives = _Object$assign__default["default"]({
|
|
128
|
+
'default-src': "'none'",
|
|
129
|
+
'script-src': _concatInstanceProperty__default["default"](_context4 = ["'self'"]).call(_context4, isMcDevEnv ?
|
|
130
|
+
// Allow webpack to load source maps on runtime when errors occur
|
|
131
|
+
// using script tags
|
|
132
|
+
['localhost:*', "'unsafe-inline'"] : _mapInstanceProperty__default["default"](htmlScriptsHashes).call(htmlScriptsHashes, assetHash => `'${assetHash}'`)),
|
|
133
|
+
'connect-src': _concatInstanceProperty__default["default"](_context5 = ["'self'", 'app.launchdarkly.com', 'clientstream.launchdarkly.com', 'events.launchdarkly.com', 'app.getsentry.com',
|
|
134
|
+
// Match all attempts to load from any subdomain of `sentry.io`
|
|
135
|
+
'*.sentry.io']).call(_context5, isMcDevEnv ? ['ws:', 'localhost:8080', 'webpack-internal:'] : []),
|
|
136
|
+
'img-src': ['*', 'data:'],
|
|
137
|
+
'style-src': _concatInstanceProperty__default["default"](_context6 = ["'self'", 'fonts.googleapis.com', 'data:']).call(_context6,
|
|
138
|
+
// TODO: investigate what needs to be done to avoid unsafe-inline styles
|
|
139
|
+
// https://github.com/commercetools/merchant-center-frontend/pull/5223#discussion_r210367636
|
|
140
|
+
["'unsafe-inline'"]
|
|
141
|
+
// TODO: enable this once we can avoid unsafe-inline
|
|
142
|
+
// htmlStylesHashes.map(assetHash => `'${assetHash}'`)
|
|
143
|
+
),
|
|
144
|
+
'font-src': ["'self'", 'fonts.gstatic.com', 'data:'],
|
|
145
|
+
// Required for Custom Views
|
|
146
|
+
'frame-src': ["'self'"]
|
|
147
|
+
}, isMcDevEnv ? {
|
|
148
|
+
// NOTE: use this instead of `upgrade-insecure-requests` for local
|
|
149
|
+
// development to avoid `http://localhost` requests to be redirected
|
|
150
|
+
// to https.
|
|
151
|
+
'block-all-mixed-content': ''
|
|
152
|
+
} : {
|
|
153
|
+
// NOTE: prefer this over `block-all-mixed-content`.
|
|
154
|
+
// https://youtu.be/j-0Bj40juMI?t=11m47s
|
|
155
|
+
'upgrade-insecure-requests': ''
|
|
156
|
+
}
|
|
157
|
+
// NOTE: we might want to define further policies in the future, for example
|
|
158
|
+
// - `require-sri-for style script` (at the moment not possible because
|
|
159
|
+
// Intercom scripts are apparently not meant for this)
|
|
160
|
+
);
|
|
161
|
+
return _objectSpread(_objectSpread({}, constants.HTTP_SECURITY_HEADERS), {}, {
|
|
162
|
+
// The `Content-Security-Policy` header is always generated
|
|
163
|
+
// based on the Merchant Center customization config.
|
|
164
|
+
[constants.HTTP_SECURITY_HEADER_KEYS['Content-Security-Policy']]: parseCSPDirectives(defaultCSPDirectives, applicationConfig.headers?.csp ?? {})
|
|
165
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
166
|
+
[constants.HTTP_SECURITY_HEADER_KEYS['Permissions-Policy']]: parsePermissionsPolicyDirectives(constants.HTTP_SECURITY_HEADERS['Permissions-Policy'], applicationConfig.headers.permissionsPolicies ?? {})
|
|
167
|
+
} : {});
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
171
|
+
const htmlScripts = {
|
|
172
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
173
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
174
|
+
}; // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
175
|
+
const htmlStyles = {
|
|
176
|
+
"loadingScreen": ".loading-screen{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;width:100vw}.loading-screen--hidden{display:none}.loading-screen>*+*{margin:24px 0 0}.loading-spinner{width:32px;height:32px}.long-loading-notice{color:#999;font-family:'Open Sans',sans-serif;font-size:12px}.long-loading-notice--hidden{visibility:hidden}.loading-spinner-circle{fill:#213c45;opacity:.2}@keyframes loading-spinner-animation{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.loading-spinner-pointer{transform-origin:20px 20px 0;animation:loading-spinner-animation .5s infinite linear}"
|
|
177
|
+
};
|
|
178
|
+
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
179
|
+
const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.replace(new RegExp('__CSP__', 'g'), options.headers?.['Content-Security-Policy'] ?? '').replace(new RegExp('__CDN_URL__', 'g'), options.env.cdnUrl ?
|
|
180
|
+
// Ensure there is a trailing slash
|
|
181
|
+
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
182
|
+
|
|
183
|
+
async function compileHtml(indexHtmlTemplatePath) {
|
|
184
|
+
const applicationConfig$1 = await applicationConfig.processConfig();
|
|
185
|
+
const compiledHeaders = processHeaders(applicationConfig$1);
|
|
186
|
+
const indexHtmlTemplateContent = fs__default["default"].readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
187
|
+
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
|
188
|
+
env: applicationConfig$1.env,
|
|
189
|
+
headers: compiledHeaders
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
env: applicationConfig$1.env,
|
|
193
|
+
headers: compiledHeaders,
|
|
194
|
+
indexHtmlContent
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
exports.generateTemplate = generateTemplate.generateTemplate;
|
|
199
|
+
exports.compileHtml = compileHtml;
|
|
200
|
+
exports.processHeaders = processHeaders;
|
|
201
|
+
exports.replaceHtmlPlaceholders = replaceHtmlPlaceholders;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { processConfig } from '@commercetools-frontend/application-config';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
4
|
+
import _slicedToArray from '@babel/runtime-corejs3/helpers/esm/slicedToArray';
|
|
5
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
6
|
+
import _reduceInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/reduce';
|
|
7
|
+
import _Object$assign from '@babel/runtime-corejs3/core-js-stable/object/assign';
|
|
8
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
9
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
10
|
+
import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
|
|
11
|
+
import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
|
|
12
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
13
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
14
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
15
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
16
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
17
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
18
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
19
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
20
|
+
import { HTTP_SECURITY_HEADER_KEYS, HTTP_SECURITY_HEADERS } from '@commercetools-frontend/constants';
|
|
21
|
+
import crypto from 'crypto';
|
|
22
|
+
import serialize from 'serialize-javascript';
|
|
23
|
+
export { g as generateTemplate } from './generate-template-31dee161.esm.js';
|
|
24
|
+
|
|
25
|
+
function createAssetHash(content) {
|
|
26
|
+
const sha256Hash = crypto.createHash('sha256').update(content).digest('base64');
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* NOTE:
|
|
30
|
+
* We prefix the hash function type as the browser
|
|
31
|
+
* needs it when validating the contents of a script against
|
|
32
|
+
* CSP headers sent.
|
|
33
|
+
* For more information head to: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Sources
|
|
34
|
+
*/
|
|
35
|
+
return `sha256-${sha256Hash}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const sanitizeAppEnvironment = env => serialize(env, {
|
|
39
|
+
isJSON: true
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
43
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context7, _context8; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(t), !0)).call(_context7, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context8 = ownKeys(Object(t))).call(_context8, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
44
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
45
|
+
const htmlScripts$1 = {
|
|
46
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
47
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
48
|
+
};
|
|
49
|
+
const toArray = value => _Array$isArray(value) ? value : [value];
|
|
50
|
+
const parseCSPDirectives = function () {
|
|
51
|
+
var _context2;
|
|
52
|
+
for (var _len = arguments.length, directives = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
directives[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
const mergedDirectives = _reduceInstanceProperty(directives).call(directives, (mergedDirectives, directive) => {
|
|
56
|
+
var _context;
|
|
57
|
+
return _Object$assign(mergedDirectives, _reduceInstanceProperty(_context = _Object$keys(directive)).call(_context, (mergedDirectiveValues, directiveKey) => {
|
|
58
|
+
const existingDirectiveValue = mergedDirectives[directiveKey];
|
|
59
|
+
return _Object$assign(mergedDirectiveValues, {
|
|
60
|
+
[directiveKey]: [...toArray(existingDirectiveValue ?? []), ...toArray(directive[directiveKey])]
|
|
61
|
+
});
|
|
62
|
+
}, {}));
|
|
63
|
+
}, {});
|
|
64
|
+
return _mapInstanceProperty(_context2 = _Object$entries(mergedDirectives)).call(_context2, _ref => {
|
|
65
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
66
|
+
directive = _ref2[0],
|
|
67
|
+
value = _ref2[1];
|
|
68
|
+
return `${directive} ${_Array$isArray(value) ? value.join(' ') : value}`;
|
|
69
|
+
}).join('; ');
|
|
70
|
+
};
|
|
71
|
+
const parsePermissionsPolicyDirectives = (defaultValue, customDirectives) => {
|
|
72
|
+
var _context3;
|
|
73
|
+
const mergedDirectives = _mapInstanceProperty(_context3 = defaultValue.split(',')).call(_context3, directive => {
|
|
74
|
+
const _directive$trim$split = _trimInstanceProperty(directive).call(directive).split('='),
|
|
75
|
+
_directive$trim$split2 = _slicedToArray(_directive$trim$split, 2),
|
|
76
|
+
directiveName = _directive$trim$split2[0],
|
|
77
|
+
directiveValue = _directive$trim$split2[1];
|
|
78
|
+
const overrideDirectiveValue = customDirectives[directiveName];
|
|
79
|
+
if (overrideDirectiveValue) {
|
|
80
|
+
return [directiveName, overrideDirectiveValue].join('=');
|
|
81
|
+
}
|
|
82
|
+
return [directiveName, directiveValue].join('=');
|
|
83
|
+
});
|
|
84
|
+
return mergedDirectives.join(', ');
|
|
85
|
+
};
|
|
86
|
+
const processHeaders = applicationConfig => {
|
|
87
|
+
var _context4, _context5, _context6;
|
|
88
|
+
const isMcDevEnv = applicationConfig.env.env === 'development';
|
|
89
|
+
|
|
90
|
+
// List hashes for injected inline scripts.
|
|
91
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src
|
|
92
|
+
const htmlScriptsHashes = [createAssetHash(htmlScripts$1.loadingScreen), createAssetHash(`window.app = ${sanitizeAppEnvironment(applicationConfig.env)};`), createAssetHash(htmlScripts$1.publicPath)];
|
|
93
|
+
|
|
94
|
+
// // List hashes for injected inline styles.
|
|
95
|
+
// // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/style-src
|
|
96
|
+
// const htmlStylesHashes = [createAssetHash(htmlStyles.loadingScreen)];
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Content Security Policy (CSP)
|
|
100
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
|
|
101
|
+
*/
|
|
102
|
+
const defaultCSPDirectives = _Object$assign({
|
|
103
|
+
'default-src': "'none'",
|
|
104
|
+
'script-src': _concatInstanceProperty(_context4 = ["'self'"]).call(_context4, isMcDevEnv ?
|
|
105
|
+
// Allow webpack to load source maps on runtime when errors occur
|
|
106
|
+
// using script tags
|
|
107
|
+
['localhost:*', "'unsafe-inline'"] : _mapInstanceProperty(htmlScriptsHashes).call(htmlScriptsHashes, assetHash => `'${assetHash}'`)),
|
|
108
|
+
'connect-src': _concatInstanceProperty(_context5 = ["'self'", 'app.launchdarkly.com', 'clientstream.launchdarkly.com', 'events.launchdarkly.com', 'app.getsentry.com',
|
|
109
|
+
// Match all attempts to load from any subdomain of `sentry.io`
|
|
110
|
+
'*.sentry.io']).call(_context5, isMcDevEnv ? ['ws:', 'localhost:8080', 'webpack-internal:'] : []),
|
|
111
|
+
'img-src': ['*', 'data:'],
|
|
112
|
+
'style-src': _concatInstanceProperty(_context6 = ["'self'", 'fonts.googleapis.com', 'data:']).call(_context6,
|
|
113
|
+
// TODO: investigate what needs to be done to avoid unsafe-inline styles
|
|
114
|
+
// https://github.com/commercetools/merchant-center-frontend/pull/5223#discussion_r210367636
|
|
115
|
+
["'unsafe-inline'"]
|
|
116
|
+
// TODO: enable this once we can avoid unsafe-inline
|
|
117
|
+
// htmlStylesHashes.map(assetHash => `'${assetHash}'`)
|
|
118
|
+
),
|
|
119
|
+
'font-src': ["'self'", 'fonts.gstatic.com', 'data:'],
|
|
120
|
+
// Required for Custom Views
|
|
121
|
+
'frame-src': ["'self'"]
|
|
122
|
+
}, isMcDevEnv ? {
|
|
123
|
+
// NOTE: use this instead of `upgrade-insecure-requests` for local
|
|
124
|
+
// development to avoid `http://localhost` requests to be redirected
|
|
125
|
+
// to https.
|
|
126
|
+
'block-all-mixed-content': ''
|
|
127
|
+
} : {
|
|
128
|
+
// NOTE: prefer this over `block-all-mixed-content`.
|
|
129
|
+
// https://youtu.be/j-0Bj40juMI?t=11m47s
|
|
130
|
+
'upgrade-insecure-requests': ''
|
|
131
|
+
}
|
|
132
|
+
// NOTE: we might want to define further policies in the future, for example
|
|
133
|
+
// - `require-sri-for style script` (at the moment not possible because
|
|
134
|
+
// Intercom scripts are apparently not meant for this)
|
|
135
|
+
);
|
|
136
|
+
return _objectSpread(_objectSpread({}, HTTP_SECURITY_HEADERS), {}, {
|
|
137
|
+
// The `Content-Security-Policy` header is always generated
|
|
138
|
+
// based on the Merchant Center customization config.
|
|
139
|
+
[HTTP_SECURITY_HEADER_KEYS['Content-Security-Policy']]: parseCSPDirectives(defaultCSPDirectives, applicationConfig.headers?.csp ?? {})
|
|
140
|
+
}, applicationConfig.headers?.permissionsPolicies ? {
|
|
141
|
+
[HTTP_SECURITY_HEADER_KEYS['Permissions-Policy']]: parsePermissionsPolicyDirectives(HTTP_SECURITY_HEADERS['Permissions-Policy'], applicationConfig.headers.permissionsPolicies ?? {})
|
|
142
|
+
} : {});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
146
|
+
const htmlScripts = {
|
|
147
|
+
"loadingScreen": "window.onAppLoaded=function(){var e=document.querySelector(\"#app-loader\");e&&e.parentNode.removeChild(e)},setTimeout(function(){var e=document.querySelector(\".loading-screen\");e&&e.classList.remove(\"loading-screen--hidden\")},250),setTimeout(function(){var e=document.querySelector(\".long-loading-notice\");e&&e.classList.remove(\"long-loading-notice--hidden\")},2e3);",
|
|
148
|
+
"publicPath": "window.__dynamicImportHandler__=function(n){return window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n.replace(/^(\\.\\/)?/,\"\")},window.__dynamicImportPreload__=function(n){return n.map(n=>window.app.cdnUrl.replace(/\\/$/,\"\")+\"/\"+n)};"
|
|
149
|
+
}; // https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
150
|
+
const htmlStyles = {
|
|
151
|
+
"loadingScreen": ".loading-screen{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;width:100vw}.loading-screen--hidden{display:none}.loading-screen>*+*{margin:24px 0 0}.loading-spinner{width:32px;height:32px}.long-loading-notice{color:#999;font-family:'Open Sans',sans-serif;font-size:12px}.long-loading-notice--hidden{visibility:hidden}.loading-spinner-circle{fill:#213c45;opacity:.2}@keyframes loading-spinner-animation{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.loading-spinner-pointer{transform-origin:20px 20px 0;animation:loading-spinner-animation .5s infinite linear}"
|
|
152
|
+
};
|
|
153
|
+
const trimTrailingSlash = value => value.replace(/\/$/, '');
|
|
154
|
+
const replaceHtmlPlaceholders = (indexHtmlContent, options) => indexHtmlContent.replace(new RegExp('__CSP__', 'g'), options.headers?.['Content-Security-Policy'] ?? '').replace(new RegExp('__CDN_URL__', 'g'), options.env.cdnUrl ?
|
|
155
|
+
// Ensure there is a trailing slash
|
|
156
|
+
`${trimTrailingSlash(options.env.cdnUrl)}/` : '').replace(new RegExp('__MC_API_URL__', 'g'), trimTrailingSlash(options.env.mcApiUrl)).replace(new RegExp('__APPLICATION_ENVIRONMENT__', 'g'), `<script>window.app = ${sanitizeAppEnvironment(options.env)};</script>`).replace(new RegExp('__LOADING_SCREEN_JS__', 'g'), `<script>${htmlScripts.loadingScreen}</script>`).replace(new RegExp('__LOADING_SCREEN_CSS__', 'g'), `<style>${htmlStyles.loadingScreen}</style>`);
|
|
157
|
+
|
|
158
|
+
async function compileHtml(indexHtmlTemplatePath) {
|
|
159
|
+
const applicationConfig = await processConfig();
|
|
160
|
+
const compiledHeaders = processHeaders(applicationConfig);
|
|
161
|
+
const indexHtmlTemplateContent = fs.readFileSync(indexHtmlTemplatePath, 'utf8');
|
|
162
|
+
const indexHtmlContent = replaceHtmlPlaceholders(indexHtmlTemplateContent, {
|
|
163
|
+
env: applicationConfig.env,
|
|
164
|
+
headers: compiledHeaders
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
env: applicationConfig.env,
|
|
168
|
+
headers: compiledHeaders,
|
|
169
|
+
indexHtmlContent
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { compileHtml, processHeaders, replaceHtmlPlaceholders };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
|
|
2
|
+
type TCompileHtmlResult = {
|
|
3
|
+
env: ApplicationRuntimeConfig['env'];
|
|
4
|
+
headers: Record<string, string | undefined>;
|
|
5
|
+
indexHtmlContent: string;
|
|
6
|
+
};
|
|
7
|
+
declare function compileHtml(indexHtmlTemplatePath: string): Promise<TCompileHtmlResult>;
|
|
8
|
+
export default compileHtml;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as compileHtml } from "./compile-html.js";
|
|
2
|
+
export { default as generateTemplate } from "./generate-template.js";
|
|
3
|
+
export { default as processHeaders } from "./process-headers.js";
|
|
4
|
+
export { default as replaceHtmlPlaceholders } from "./replace-html-placeholders.js";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
|
|
2
|
+
import { type THttpSecurityHeaders } from '@commercetools-frontend/constants';
|
|
3
|
+
declare const processHeaders: (applicationConfig: ApplicationRuntimeConfig) => Record<THttpSecurityHeaders, string | undefined>;
|
|
4
|
+
export default processHeaders;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApplicationRuntimeConfig } from '@commercetools-frontend/application-config';
|
|
2
|
+
import type { THttpSecurityHeaders } from '@commercetools-frontend/constants';
|
|
3
|
+
type TReplaceHtmlPlaceholdersOptions = {
|
|
4
|
+
env: ApplicationRuntimeConfig['env'];
|
|
5
|
+
headers?: Record<THttpSecurityHeaders, string | undefined>;
|
|
6
|
+
};
|
|
7
|
+
declare const replaceHtmlPlaceholders: (indexHtmlContent: string, options: TReplaceHtmlPlaceholdersOptions) => string;
|
|
8
|
+
export default replaceHtmlPlaceholders;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
4
|
+
const htmlDocs = {
|
|
5
|
+
"application": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <!-- do not index this page, do not follow links on this page -->\n <meta name=\"robots\" content=\"noindex,nofollow\" />\n\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1, maximum-scale=1\"\n />\n <meta name=\"referrer\" content=\"no-referrer\" />\n\n <meta http-equiv=\"Content-Security-Policy\" content=\"__CSP__\" />\n\n <!-- Preconnects -->\n <link rel=\"preconnect\" href=\"__CDN_URL__\" />\n <link rel=\"preconnect\" href=\"__MC_API_URL__\" />\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin />\n <link rel=\"preconnect\" href=\"https://app.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://clientstream.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://events.launchdarkly.com\" />\n\n <!-- Fav and touch icons -->\n <link rel=\"shortcut icon\" type=\"image/png\" href=\"__CDN_URL__favicon.png\" />\n <!-- Standard iPhone -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <!-- Standard iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <!-- Retina iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n\n <!-- Main application chunks -->\n __APPLICATION_SCRIPT_IMPORTS__\n\n <!-- Fonts -->\n <link\n href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Open+Sans:ital,wght@0,300;0,400;0,700;1,400;1,700&display=swap\"\n rel=\"stylesheet\"\n />\n\n __APPLICATION_CSS_IMPORTS__\n\n <title>Merchant Center</title>\n </head>\n <body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n\n <div id=\"app-loader\">\n <!-- Loading screen styles -->\n __LOADING_SCREEN_CSS__\n\n <div class=\"loading-screen loading-screen--hidden\">\n <svg class=\"loading-spinner\" viewBox=\"0 0 40 40\">\n <path\n class=\"loading-spinner-circle\"\n d=\"M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946, 14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z\"\n ></path>\n <path\n class=\"loading-spinner-pointer\"\n d=\"M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z\"\n ></path>\n </svg>\n <svg\n width=\"200\"\n height=\"29\"\n viewBox=\"0 0 200 29\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_5_959)\">\n <path\n d=\"M0.338463 21.6833V8.78347C0.338463 8.42599 0.724659 8.20364 1.03425 8.38131L12.2063 14.8307C12.4936 14.9967 12.6702 15.3031 12.6702 15.6339V28.5338C12.6702 28.8912 12.284 29.1136 11.9744 28.9359L0.802324 22.4865C0.51507 22.3206 0.338463 22.0142 0.338463 21.6833Z\"\n fill=\"#6359FF\"\n />\n <path\n d=\"M1.7875 6.47385L12.7851 0.124477C13.0723 -0.0414922 13.4255 -0.0414922 13.7128 0.124477L24.7104 6.47385C25.0966 6.69727 25.0966 7.25475 24.7104 7.47817L13.7128 13.8275C13.4255 13.9935 13.0723 13.9935 12.7851 13.8275L1.7875 7.47817C1.40131 7.25475 1.40131 6.69727 1.7875 6.47385Z\"\n fill=\"#FFC806\"\n />\n <path\n d=\"M13.8287 28.5351V16.5725C13.8287 16.2151 14.2149 15.9927 14.5245 16.1704L24.7103 22.0516C25.0965 22.275 25.0965 22.8325 24.7103 23.056L14.5245 28.9372C14.2149 29.1159 13.8287 28.8925 13.8287 28.5351Z\"\n fill=\"#0BBFBF\"\n />\n <path\n d=\"M99.5461 17.9441C99.3026 20.0081 98.4412 20.8404 96.9764 20.8404C95.16 20.8404 94.1987 19.5816 94.1987 16.9704V16.7103H102.43C102.496 16.0465 102.521 15.4764 102.521 14.8689C102.521 10.9364 100.532 8.72876 96.964 8.72876C93.1313 8.72876 91.0548 11.0487 91.0548 15.26V16.4647C91.0548 20.674 93.1189 22.9877 96.8724 22.9877C100.145 22.9877 102.12 21.4397 102.584 18.3374L99.5461 17.9462V17.9441ZM96.9348 10.8677C98.5598 10.8677 99.3775 11.9205 99.3775 14.1926V14.5443H94.1987C94.2611 12.0891 95.1725 10.8677 96.9348 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M39.2811 17.5174L42.5166 17.921C42.1379 21.2335 40.1904 23 36.8176 23C32.985 23 31 20.5323 31 15.805V15.7509C31 11.1297 33.0349 8.71191 36.8301 8.71191C40.2549 8.71191 42.0901 10.5325 42.3626 13.9719L39.2062 14.3485C39.0627 11.9723 38.3323 10.8821 36.8176 10.8821C35.0761 10.8821 34.2563 12.2845 34.2563 15.2349V16.3231C34.2563 19.3609 35.101 20.8069 36.855 20.8069C38.349 20.8069 39.1376 19.7167 39.2811 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M49.7678 8.70972C46.0017 8.70972 43.9127 11.3335 43.9127 15.7112V15.9963C43.9127 20.3449 46.0038 22.9978 49.7678 22.9978C53.5317 22.9978 55.6228 20.3449 55.6228 15.9963V15.7112C55.6228 11.3335 53.5317 8.70972 49.7678 8.70972ZM52.3666 16.4623C52.3666 19.4128 51.5051 20.8151 49.7678 20.8151C48.0304 20.8151 47.169 19.4128 47.169 16.4623V15.2451C47.169 12.2947 48.0117 10.8799 49.7678 10.8799C51.5239 10.8799 52.3666 12.2947 52.3666 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M164.649 8.70972C160.883 8.70972 158.794 11.3335 158.794 15.7112V15.9963C158.794 20.3449 160.883 22.9978 164.649 22.9978C168.415 22.9978 170.508 20.3449 170.508 15.9963V15.7112C170.508 11.3335 168.413 8.70972 164.649 8.70972ZM167.247 16.4623C167.247 19.4128 166.392 20.8151 164.649 20.8151C162.905 20.8151 162.054 19.4128 162.054 16.4623V15.2451C162.054 12.2947 162.897 10.8799 164.649 10.8799C166.401 10.8799 167.247 12.2947 167.247 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path d=\"M175.397 5H172.229V22.6713H175.397V5Z\" fill=\"#191741\" />\n <path\n d=\"M120.386 17.5174L123.622 17.921C123.243 21.2335 121.298 23 117.923 23C114.09 23 112.105 20.5323 112.105 15.805V15.7509C112.105 11.1297 114.14 8.71191 117.935 8.71191C121.36 8.71191 123.195 10.5325 123.468 13.9719L120.311 14.3485C120.168 11.9723 119.437 10.8821 117.923 10.8821C116.181 10.8821 115.361 12.2845 115.361 15.2349V16.3231C115.361 19.3609 116.206 20.8069 117.96 20.8069C119.454 20.8069 120.243 19.7167 120.386 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M187.746 19.0112C187.746 21.4914 185.824 22.9853 182.511 22.9853C178.98 22.9853 176.954 21.4373 176.866 18.6824L179.875 18.0728C179.85 19.8518 180.786 20.8526 182.499 20.8526C183.839 20.8526 184.577 20.3324 184.577 19.3087C184.577 18.285 183.918 17.8273 182.176 17.1802L180.435 16.5164C178.697 15.8527 177.203 14.5814 177.203 12.6838C177.203 10.1641 178.957 8.70972 182.139 8.70972C185.32 8.70972 187.318 10.1537 187.33 12.6838L184.384 13.204C184.446 11.5915 183.645 10.8778 182.176 10.8778C180.893 10.8778 180.179 11.3605 180.179 12.2302C180.179 13.1 180.801 13.6701 182.542 14.2943L184.28 14.9289C186.021 15.5677 187.746 16.5539 187.746 19.0091V19.0112Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M151.578 8.70972C147.812 8.70972 145.723 11.3335 145.723 15.7112V15.9963C145.723 20.3449 147.812 22.9978 151.578 22.9978C155.344 22.9978 157.437 20.3449 157.437 15.9963V15.7112C157.437 11.3335 155.342 8.70972 151.578 8.70972ZM154.177 16.4623C154.177 19.4128 153.319 20.8151 151.578 20.8151C149.836 20.8151 148.983 19.4128 148.983 16.4623V15.2451C148.983 12.2947 149.826 10.8799 151.578 10.8799C153.33 10.8799 154.177 12.2947 154.177 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M143.001 20.476C143.588 20.476 144.314 20.32 145.003 20.0224L144.822 22.3361C144.104 22.7127 142.999 22.9707 141.963 22.9707C139.495 22.9707 138.224 21.7244 138.224 19.0507V5.95074L141.393 5.00195V9.04056H144.965V11.3376H141.393V18.6741C141.393 19.9746 141.925 20.4781 143.001 20.4781V20.476Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M133.511 17.9441C133.268 20.0081 132.408 20.8404 130.941 20.8404C129.123 20.8404 128.164 19.5816 128.164 16.9704V16.7103H136.395C136.462 16.0465 136.487 15.4764 136.487 14.8689C136.487 10.9364 134.497 8.72876 130.929 8.72876C127.096 8.72876 125.02 11.0487 125.02 15.26V16.4647C125.02 20.674 127.084 22.9877 130.837 22.9877C134.112 22.9877 136.085 21.4397 136.551 18.3374L133.511 17.9462V17.9441ZM130.9 10.8677C132.525 10.8677 133.343 11.9205 133.343 14.1926V14.5443H128.164C128.226 12.0891 129.138 10.8677 130.9 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M67.1602 12.6589C68.1361 9.94148 69.6383 8.70972 71.5733 8.70972C73.6644 8.70972 74.6278 10.2036 74.1243 12.5798L74.3843 12.6589C75.3602 9.94148 76.8624 8.70972 78.7975 8.70972C80.8886 8.70972 81.8519 10.2036 81.3484 12.5798L81.6085 12.6589C82.5656 9.93108 84.0574 8.70972 86.0986 8.70972C88.3187 8.70972 89.3736 10.0351 89.3736 12.5673V22.6711H86.2047V13.102C86.2047 11.7517 85.6845 11.0796 84.6442 11.0796C83.0608 11.0796 82.1515 13.0271 82.1515 15.6342V22.6732H78.9993V13.1291C78.9993 11.8058 78.4063 11.0796 77.4201 11.0796C75.8388 11.0796 74.9274 13.0271 74.9274 15.6342V22.6732H71.7752V13.1291C71.7752 11.8058 71.23 11.063 70.2438 11.063H70.2396V11.0817C70.2396 11.0817 70.2355 11.0817 70.2334 11.0817C68.6521 11.0817 67.7407 13.0292 67.7407 15.6363V22.6753H64.5885V13.1312C64.5885 11.8079 64.0433 11.065 63.0571 11.065C61.5257 11.065 60.5083 12.9377 60.5083 15.7154V22.6753H57.3394V9.04262H60.5207C60.5499 9.87282 60.3917 10.6115 59.7946 12.4549L60.0547 12.5715C61.276 9.77919 62.5349 8.71388 64.3908 8.71388C66.4819 8.71388 67.4432 10.2078 66.9397 12.5839L67.1644 12.663L67.1602 12.6589Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M111.841 11.4895C108.304 11.7288 107.476 12.9106 107.476 16.712V22.6711H104.307V9.03848H107.488C107.517 9.99976 107.388 10.6885 106.749 12.5174L107.009 12.6339C107.896 10.572 108.926 8.67436 112.066 8.60986L111.841 11.4875V11.4895Z\"\n fill=\"#191741\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_5_959\">\n <rect width=\"200\" height=\"29\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n <p class=\"long-loading-notice long-loading-notice--hidden\">\n Sorry, this is taking an unusually long time.\n </p>\n </div>\n </div>\n <div id=\"app\"></div>\n\n <!-- Loading screen handling -->\n __LOADING_SCREEN_JS__\n\n <!-- Application globals -->\n __APPLICATION_ENVIRONMENT__\n </body>\n</html>\n"
|
|
6
|
+
};
|
|
7
|
+
function generateTemplate(_ref) {
|
|
8
|
+
let _ref$cssImports = _ref.cssImports,
|
|
9
|
+
cssImports = _ref$cssImports === void 0 ? [] : _ref$cssImports,
|
|
10
|
+
_ref$scriptImports = _ref.scriptImports,
|
|
11
|
+
scriptImports = _ref$scriptImports === void 0 ? [] : _ref$scriptImports;
|
|
12
|
+
return htmlDocs.application.replace(new RegExp('__APPLICATION_CSS_IMPORTS__', 'g'), cssImports.join('\n')).replace(new RegExp('__APPLICATION_SCRIPT_IMPORTS__', 'g'), scriptImports.join('\n'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.generateTemplate = generateTemplate;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
2
|
+
const htmlDocs = {
|
|
3
|
+
"application": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <!-- do not index this page, do not follow links on this page -->\n <meta name=\"robots\" content=\"noindex,nofollow\" />\n\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1, maximum-scale=1\"\n />\n <meta name=\"referrer\" content=\"no-referrer\" />\n\n <meta http-equiv=\"Content-Security-Policy\" content=\"__CSP__\" />\n\n <!-- Preconnects -->\n <link rel=\"preconnect\" href=\"__CDN_URL__\" />\n <link rel=\"preconnect\" href=\"__MC_API_URL__\" />\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin />\n <link rel=\"preconnect\" href=\"https://app.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://clientstream.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://events.launchdarkly.com\" />\n\n <!-- Fav and touch icons -->\n <link rel=\"shortcut icon\" type=\"image/png\" href=\"__CDN_URL__favicon.png\" />\n <!-- Standard iPhone -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <!-- Standard iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <!-- Retina iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n\n <!-- Main application chunks -->\n __APPLICATION_SCRIPT_IMPORTS__\n\n <!-- Fonts -->\n <link\n href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Open+Sans:ital,wght@0,300;0,400;0,700;1,400;1,700&display=swap\"\n rel=\"stylesheet\"\n />\n\n __APPLICATION_CSS_IMPORTS__\n\n <title>Merchant Center</title>\n </head>\n <body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n\n <div id=\"app-loader\">\n <!-- Loading screen styles -->\n __LOADING_SCREEN_CSS__\n\n <div class=\"loading-screen loading-screen--hidden\">\n <svg class=\"loading-spinner\" viewBox=\"0 0 40 40\">\n <path\n class=\"loading-spinner-circle\"\n d=\"M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946, 14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z\"\n ></path>\n <path\n class=\"loading-spinner-pointer\"\n d=\"M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z\"\n ></path>\n </svg>\n <svg\n width=\"200\"\n height=\"29\"\n viewBox=\"0 0 200 29\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_5_959)\">\n <path\n d=\"M0.338463 21.6833V8.78347C0.338463 8.42599 0.724659 8.20364 1.03425 8.38131L12.2063 14.8307C12.4936 14.9967 12.6702 15.3031 12.6702 15.6339V28.5338C12.6702 28.8912 12.284 29.1136 11.9744 28.9359L0.802324 22.4865C0.51507 22.3206 0.338463 22.0142 0.338463 21.6833Z\"\n fill=\"#6359FF\"\n />\n <path\n d=\"M1.7875 6.47385L12.7851 0.124477C13.0723 -0.0414922 13.4255 -0.0414922 13.7128 0.124477L24.7104 6.47385C25.0966 6.69727 25.0966 7.25475 24.7104 7.47817L13.7128 13.8275C13.4255 13.9935 13.0723 13.9935 12.7851 13.8275L1.7875 7.47817C1.40131 7.25475 1.40131 6.69727 1.7875 6.47385Z\"\n fill=\"#FFC806\"\n />\n <path\n d=\"M13.8287 28.5351V16.5725C13.8287 16.2151 14.2149 15.9927 14.5245 16.1704L24.7103 22.0516C25.0965 22.275 25.0965 22.8325 24.7103 23.056L14.5245 28.9372C14.2149 29.1159 13.8287 28.8925 13.8287 28.5351Z\"\n fill=\"#0BBFBF\"\n />\n <path\n d=\"M99.5461 17.9441C99.3026 20.0081 98.4412 20.8404 96.9764 20.8404C95.16 20.8404 94.1987 19.5816 94.1987 16.9704V16.7103H102.43C102.496 16.0465 102.521 15.4764 102.521 14.8689C102.521 10.9364 100.532 8.72876 96.964 8.72876C93.1313 8.72876 91.0548 11.0487 91.0548 15.26V16.4647C91.0548 20.674 93.1189 22.9877 96.8724 22.9877C100.145 22.9877 102.12 21.4397 102.584 18.3374L99.5461 17.9462V17.9441ZM96.9348 10.8677C98.5598 10.8677 99.3775 11.9205 99.3775 14.1926V14.5443H94.1987C94.2611 12.0891 95.1725 10.8677 96.9348 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M39.2811 17.5174L42.5166 17.921C42.1379 21.2335 40.1904 23 36.8176 23C32.985 23 31 20.5323 31 15.805V15.7509C31 11.1297 33.0349 8.71191 36.8301 8.71191C40.2549 8.71191 42.0901 10.5325 42.3626 13.9719L39.2062 14.3485C39.0627 11.9723 38.3323 10.8821 36.8176 10.8821C35.0761 10.8821 34.2563 12.2845 34.2563 15.2349V16.3231C34.2563 19.3609 35.101 20.8069 36.855 20.8069C38.349 20.8069 39.1376 19.7167 39.2811 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M49.7678 8.70972C46.0017 8.70972 43.9127 11.3335 43.9127 15.7112V15.9963C43.9127 20.3449 46.0038 22.9978 49.7678 22.9978C53.5317 22.9978 55.6228 20.3449 55.6228 15.9963V15.7112C55.6228 11.3335 53.5317 8.70972 49.7678 8.70972ZM52.3666 16.4623C52.3666 19.4128 51.5051 20.8151 49.7678 20.8151C48.0304 20.8151 47.169 19.4128 47.169 16.4623V15.2451C47.169 12.2947 48.0117 10.8799 49.7678 10.8799C51.5239 10.8799 52.3666 12.2947 52.3666 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M164.649 8.70972C160.883 8.70972 158.794 11.3335 158.794 15.7112V15.9963C158.794 20.3449 160.883 22.9978 164.649 22.9978C168.415 22.9978 170.508 20.3449 170.508 15.9963V15.7112C170.508 11.3335 168.413 8.70972 164.649 8.70972ZM167.247 16.4623C167.247 19.4128 166.392 20.8151 164.649 20.8151C162.905 20.8151 162.054 19.4128 162.054 16.4623V15.2451C162.054 12.2947 162.897 10.8799 164.649 10.8799C166.401 10.8799 167.247 12.2947 167.247 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path d=\"M175.397 5H172.229V22.6713H175.397V5Z\" fill=\"#191741\" />\n <path\n d=\"M120.386 17.5174L123.622 17.921C123.243 21.2335 121.298 23 117.923 23C114.09 23 112.105 20.5323 112.105 15.805V15.7509C112.105 11.1297 114.14 8.71191 117.935 8.71191C121.36 8.71191 123.195 10.5325 123.468 13.9719L120.311 14.3485C120.168 11.9723 119.437 10.8821 117.923 10.8821C116.181 10.8821 115.361 12.2845 115.361 15.2349V16.3231C115.361 19.3609 116.206 20.8069 117.96 20.8069C119.454 20.8069 120.243 19.7167 120.386 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M187.746 19.0112C187.746 21.4914 185.824 22.9853 182.511 22.9853C178.98 22.9853 176.954 21.4373 176.866 18.6824L179.875 18.0728C179.85 19.8518 180.786 20.8526 182.499 20.8526C183.839 20.8526 184.577 20.3324 184.577 19.3087C184.577 18.285 183.918 17.8273 182.176 17.1802L180.435 16.5164C178.697 15.8527 177.203 14.5814 177.203 12.6838C177.203 10.1641 178.957 8.70972 182.139 8.70972C185.32 8.70972 187.318 10.1537 187.33 12.6838L184.384 13.204C184.446 11.5915 183.645 10.8778 182.176 10.8778C180.893 10.8778 180.179 11.3605 180.179 12.2302C180.179 13.1 180.801 13.6701 182.542 14.2943L184.28 14.9289C186.021 15.5677 187.746 16.5539 187.746 19.0091V19.0112Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M151.578 8.70972C147.812 8.70972 145.723 11.3335 145.723 15.7112V15.9963C145.723 20.3449 147.812 22.9978 151.578 22.9978C155.344 22.9978 157.437 20.3449 157.437 15.9963V15.7112C157.437 11.3335 155.342 8.70972 151.578 8.70972ZM154.177 16.4623C154.177 19.4128 153.319 20.8151 151.578 20.8151C149.836 20.8151 148.983 19.4128 148.983 16.4623V15.2451C148.983 12.2947 149.826 10.8799 151.578 10.8799C153.33 10.8799 154.177 12.2947 154.177 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M143.001 20.476C143.588 20.476 144.314 20.32 145.003 20.0224L144.822 22.3361C144.104 22.7127 142.999 22.9707 141.963 22.9707C139.495 22.9707 138.224 21.7244 138.224 19.0507V5.95074L141.393 5.00195V9.04056H144.965V11.3376H141.393V18.6741C141.393 19.9746 141.925 20.4781 143.001 20.4781V20.476Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M133.511 17.9441C133.268 20.0081 132.408 20.8404 130.941 20.8404C129.123 20.8404 128.164 19.5816 128.164 16.9704V16.7103H136.395C136.462 16.0465 136.487 15.4764 136.487 14.8689C136.487 10.9364 134.497 8.72876 130.929 8.72876C127.096 8.72876 125.02 11.0487 125.02 15.26V16.4647C125.02 20.674 127.084 22.9877 130.837 22.9877C134.112 22.9877 136.085 21.4397 136.551 18.3374L133.511 17.9462V17.9441ZM130.9 10.8677C132.525 10.8677 133.343 11.9205 133.343 14.1926V14.5443H128.164C128.226 12.0891 129.138 10.8677 130.9 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M67.1602 12.6589C68.1361 9.94148 69.6383 8.70972 71.5733 8.70972C73.6644 8.70972 74.6278 10.2036 74.1243 12.5798L74.3843 12.6589C75.3602 9.94148 76.8624 8.70972 78.7975 8.70972C80.8886 8.70972 81.8519 10.2036 81.3484 12.5798L81.6085 12.6589C82.5656 9.93108 84.0574 8.70972 86.0986 8.70972C88.3187 8.70972 89.3736 10.0351 89.3736 12.5673V22.6711H86.2047V13.102C86.2047 11.7517 85.6845 11.0796 84.6442 11.0796C83.0608 11.0796 82.1515 13.0271 82.1515 15.6342V22.6732H78.9993V13.1291C78.9993 11.8058 78.4063 11.0796 77.4201 11.0796C75.8388 11.0796 74.9274 13.0271 74.9274 15.6342V22.6732H71.7752V13.1291C71.7752 11.8058 71.23 11.063 70.2438 11.063H70.2396V11.0817C70.2396 11.0817 70.2355 11.0817 70.2334 11.0817C68.6521 11.0817 67.7407 13.0292 67.7407 15.6363V22.6753H64.5885V13.1312C64.5885 11.8079 64.0433 11.065 63.0571 11.065C61.5257 11.065 60.5083 12.9377 60.5083 15.7154V22.6753H57.3394V9.04262H60.5207C60.5499 9.87282 60.3917 10.6115 59.7946 12.4549L60.0547 12.5715C61.276 9.77919 62.5349 8.71388 64.3908 8.71388C66.4819 8.71388 67.4432 10.2078 66.9397 12.5839L67.1644 12.663L67.1602 12.6589Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M111.841 11.4895C108.304 11.7288 107.476 12.9106 107.476 16.712V22.6711H104.307V9.03848H107.488C107.517 9.99976 107.388 10.6885 106.749 12.5174L107.009 12.6339C107.896 10.572 108.926 8.67436 112.066 8.60986L111.841 11.4875V11.4895Z\"\n fill=\"#191741\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_5_959\">\n <rect width=\"200\" height=\"29\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n <p class=\"long-loading-notice long-loading-notice--hidden\">\n Sorry, this is taking an unusually long time.\n </p>\n </div>\n </div>\n <div id=\"app\"></div>\n\n <!-- Loading screen handling -->\n __LOADING_SCREEN_JS__\n\n <!-- Application globals -->\n __APPLICATION_ENVIRONMENT__\n </body>\n</html>\n"
|
|
4
|
+
};
|
|
5
|
+
function generateTemplate(_ref) {
|
|
6
|
+
let _ref$cssImports = _ref.cssImports,
|
|
7
|
+
cssImports = _ref$cssImports === void 0 ? [] : _ref$cssImports,
|
|
8
|
+
_ref$scriptImports = _ref.scriptImports,
|
|
9
|
+
scriptImports = _ref$scriptImports === void 0 ? [] : _ref$scriptImports;
|
|
10
|
+
return htmlDocs.application.replace(new RegExp('__APPLICATION_CSS_IMPORTS__', 'g'), cssImports.join('\n')).replace(new RegExp('__APPLICATION_SCRIPT_IMPORTS__', 'g'), scriptImports.join('\n'));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { generateTemplate as g };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://babeljs.io/blog/2017/09/11/zero-config-with-babel-macros
|
|
4
|
+
const htmlDocs = {
|
|
5
|
+
"application": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <!-- do not index this page, do not follow links on this page -->\n <meta name=\"robots\" content=\"noindex,nofollow\" />\n\n <meta\n name=\"viewport\"\n content=\"width=device-width, initial-scale=1, maximum-scale=1\"\n />\n <meta name=\"referrer\" content=\"no-referrer\" />\n\n <meta http-equiv=\"Content-Security-Policy\" content=\"__CSP__\" />\n\n <!-- Preconnects -->\n <link rel=\"preconnect\" href=\"__CDN_URL__\" />\n <link rel=\"preconnect\" href=\"__MC_API_URL__\" />\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin />\n <link rel=\"preconnect\" href=\"https://app.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://clientstream.launchdarkly.com\" />\n <link rel=\"preconnect\" href=\"https://events.launchdarkly.com\" />\n\n <!-- Fav and touch icons -->\n <link rel=\"shortcut icon\" type=\"image/png\" href=\"__CDN_URL__favicon.png\" />\n <!-- Standard iPhone -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"57x57\"\n href=\"__CDN_URL__favicon_57x57px.png\"\n />\n <!-- Standard iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"72x72\"\n href=\"__CDN_URL__favicon_72x72px.png\"\n />\n <!-- Retina iPad -->\n <link\n rel=\"apple-touch-icon\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n <link\n rel=\"apple-touch-icon-precomposed\"\n sizes=\"144x144\"\n href=\"__CDN_URL__favicon_144x144px.png\"\n />\n\n <!-- Main application chunks -->\n __APPLICATION_SCRIPT_IMPORTS__\n\n <!-- Fonts -->\n <link\n href=\"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Open+Sans:ital,wght@0,300;0,400;0,700;1,400;1,700&display=swap\"\n rel=\"stylesheet\"\n />\n\n __APPLICATION_CSS_IMPORTS__\n\n <title>Merchant Center</title>\n </head>\n <body>\n <noscript>You need to enable JavaScript to run this app.</noscript>\n\n <div id=\"app-loader\">\n <!-- Loading screen styles -->\n __LOADING_SCREEN_CSS__\n\n <div class=\"loading-screen loading-screen--hidden\">\n <svg class=\"loading-spinner\" viewBox=\"0 0 40 40\">\n <path\n class=\"loading-spinner-circle\"\n d=\"M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946, 14.946,14.946 s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,26.541,26.626,31.749,20.201,31.749z\"\n ></path>\n <path\n class=\"loading-spinner-pointer\"\n d=\"M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0 C22.32,8.481,24.301,9.057,26.013,10.047z\"\n ></path>\n </svg>\n <svg\n width=\"200\"\n height=\"29\"\n viewBox=\"0 0 200 29\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_5_959)\">\n <path\n d=\"M0.338463 21.6833V8.78347C0.338463 8.42599 0.724659 8.20364 1.03425 8.38131L12.2063 14.8307C12.4936 14.9967 12.6702 15.3031 12.6702 15.6339V28.5338C12.6702 28.8912 12.284 29.1136 11.9744 28.9359L0.802324 22.4865C0.51507 22.3206 0.338463 22.0142 0.338463 21.6833Z\"\n fill=\"#6359FF\"\n />\n <path\n d=\"M1.7875 6.47385L12.7851 0.124477C13.0723 -0.0414922 13.4255 -0.0414922 13.7128 0.124477L24.7104 6.47385C25.0966 6.69727 25.0966 7.25475 24.7104 7.47817L13.7128 13.8275C13.4255 13.9935 13.0723 13.9935 12.7851 13.8275L1.7875 7.47817C1.40131 7.25475 1.40131 6.69727 1.7875 6.47385Z\"\n fill=\"#FFC806\"\n />\n <path\n d=\"M13.8287 28.5351V16.5725C13.8287 16.2151 14.2149 15.9927 14.5245 16.1704L24.7103 22.0516C25.0965 22.275 25.0965 22.8325 24.7103 23.056L14.5245 28.9372C14.2149 29.1159 13.8287 28.8925 13.8287 28.5351Z\"\n fill=\"#0BBFBF\"\n />\n <path\n d=\"M99.5461 17.9441C99.3026 20.0081 98.4412 20.8404 96.9764 20.8404C95.16 20.8404 94.1987 19.5816 94.1987 16.9704V16.7103H102.43C102.496 16.0465 102.521 15.4764 102.521 14.8689C102.521 10.9364 100.532 8.72876 96.964 8.72876C93.1313 8.72876 91.0548 11.0487 91.0548 15.26V16.4647C91.0548 20.674 93.1189 22.9877 96.8724 22.9877C100.145 22.9877 102.12 21.4397 102.584 18.3374L99.5461 17.9462V17.9441ZM96.9348 10.8677C98.5598 10.8677 99.3775 11.9205 99.3775 14.1926V14.5443H94.1987C94.2611 12.0891 95.1725 10.8677 96.9348 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M39.2811 17.5174L42.5166 17.921C42.1379 21.2335 40.1904 23 36.8176 23C32.985 23 31 20.5323 31 15.805V15.7509C31 11.1297 33.0349 8.71191 36.8301 8.71191C40.2549 8.71191 42.0901 10.5325 42.3626 13.9719L39.2062 14.3485C39.0627 11.9723 38.3323 10.8821 36.8176 10.8821C35.0761 10.8821 34.2563 12.2845 34.2563 15.2349V16.3231C34.2563 19.3609 35.101 20.8069 36.855 20.8069C38.349 20.8069 39.1376 19.7167 39.2811 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M49.7678 8.70972C46.0017 8.70972 43.9127 11.3335 43.9127 15.7112V15.9963C43.9127 20.3449 46.0038 22.9978 49.7678 22.9978C53.5317 22.9978 55.6228 20.3449 55.6228 15.9963V15.7112C55.6228 11.3335 53.5317 8.70972 49.7678 8.70972ZM52.3666 16.4623C52.3666 19.4128 51.5051 20.8151 49.7678 20.8151C48.0304 20.8151 47.169 19.4128 47.169 16.4623V15.2451C47.169 12.2947 48.0117 10.8799 49.7678 10.8799C51.5239 10.8799 52.3666 12.2947 52.3666 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M164.649 8.70972C160.883 8.70972 158.794 11.3335 158.794 15.7112V15.9963C158.794 20.3449 160.883 22.9978 164.649 22.9978C168.415 22.9978 170.508 20.3449 170.508 15.9963V15.7112C170.508 11.3335 168.413 8.70972 164.649 8.70972ZM167.247 16.4623C167.247 19.4128 166.392 20.8151 164.649 20.8151C162.905 20.8151 162.054 19.4128 162.054 16.4623V15.2451C162.054 12.2947 162.897 10.8799 164.649 10.8799C166.401 10.8799 167.247 12.2947 167.247 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path d=\"M175.397 5H172.229V22.6713H175.397V5Z\" fill=\"#191741\" />\n <path\n d=\"M120.386 17.5174L123.622 17.921C123.243 21.2335 121.298 23 117.923 23C114.09 23 112.105 20.5323 112.105 15.805V15.7509C112.105 11.1297 114.14 8.71191 117.935 8.71191C121.36 8.71191 123.195 10.5325 123.468 13.9719L120.311 14.3485C120.168 11.9723 119.437 10.8821 117.923 10.8821C116.181 10.8821 115.361 12.2845 115.361 15.2349V16.3231C115.361 19.3609 116.206 20.8069 117.96 20.8069C119.454 20.8069 120.243 19.7167 120.386 17.5195V17.5174Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M187.746 19.0112C187.746 21.4914 185.824 22.9853 182.511 22.9853C178.98 22.9853 176.954 21.4373 176.866 18.6824L179.875 18.0728C179.85 19.8518 180.786 20.8526 182.499 20.8526C183.839 20.8526 184.577 20.3324 184.577 19.3087C184.577 18.285 183.918 17.8273 182.176 17.1802L180.435 16.5164C178.697 15.8527 177.203 14.5814 177.203 12.6838C177.203 10.1641 178.957 8.70972 182.139 8.70972C185.32 8.70972 187.318 10.1537 187.33 12.6838L184.384 13.204C184.446 11.5915 183.645 10.8778 182.176 10.8778C180.893 10.8778 180.179 11.3605 180.179 12.2302C180.179 13.1 180.801 13.6701 182.542 14.2943L184.28 14.9289C186.021 15.5677 187.746 16.5539 187.746 19.0091V19.0112Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M151.578 8.70972C147.812 8.70972 145.723 11.3335 145.723 15.7112V15.9963C145.723 20.3449 147.812 22.9978 151.578 22.9978C155.344 22.9978 157.437 20.3449 157.437 15.9963V15.7112C157.437 11.3335 155.342 8.70972 151.578 8.70972ZM154.177 16.4623C154.177 19.4128 153.319 20.8151 151.578 20.8151C149.836 20.8151 148.983 19.4128 148.983 16.4623V15.2451C148.983 12.2947 149.826 10.8799 151.578 10.8799C153.33 10.8799 154.177 12.2947 154.177 15.2451V16.4623Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M143.001 20.476C143.588 20.476 144.314 20.32 145.003 20.0224L144.822 22.3361C144.104 22.7127 142.999 22.9707 141.963 22.9707C139.495 22.9707 138.224 21.7244 138.224 19.0507V5.95074L141.393 5.00195V9.04056H144.965V11.3376H141.393V18.6741C141.393 19.9746 141.925 20.4781 143.001 20.4781V20.476Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M133.511 17.9441C133.268 20.0081 132.408 20.8404 130.941 20.8404C129.123 20.8404 128.164 19.5816 128.164 16.9704V16.7103H136.395C136.462 16.0465 136.487 15.4764 136.487 14.8689C136.487 10.9364 134.497 8.72876 130.929 8.72876C127.096 8.72876 125.02 11.0487 125.02 15.26V16.4647C125.02 20.674 127.084 22.9877 130.837 22.9877C134.112 22.9877 136.085 21.4397 136.551 18.3374L133.511 17.9462V17.9441ZM130.9 10.8677C132.525 10.8677 133.343 11.9205 133.343 14.1926V14.5443H128.164C128.226 12.0891 129.138 10.8677 130.9 10.8677Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M67.1602 12.6589C68.1361 9.94148 69.6383 8.70972 71.5733 8.70972C73.6644 8.70972 74.6278 10.2036 74.1243 12.5798L74.3843 12.6589C75.3602 9.94148 76.8624 8.70972 78.7975 8.70972C80.8886 8.70972 81.8519 10.2036 81.3484 12.5798L81.6085 12.6589C82.5656 9.93108 84.0574 8.70972 86.0986 8.70972C88.3187 8.70972 89.3736 10.0351 89.3736 12.5673V22.6711H86.2047V13.102C86.2047 11.7517 85.6845 11.0796 84.6442 11.0796C83.0608 11.0796 82.1515 13.0271 82.1515 15.6342V22.6732H78.9993V13.1291C78.9993 11.8058 78.4063 11.0796 77.4201 11.0796C75.8388 11.0796 74.9274 13.0271 74.9274 15.6342V22.6732H71.7752V13.1291C71.7752 11.8058 71.23 11.063 70.2438 11.063H70.2396V11.0817C70.2396 11.0817 70.2355 11.0817 70.2334 11.0817C68.6521 11.0817 67.7407 13.0292 67.7407 15.6363V22.6753H64.5885V13.1312C64.5885 11.8079 64.0433 11.065 63.0571 11.065C61.5257 11.065 60.5083 12.9377 60.5083 15.7154V22.6753H57.3394V9.04262H60.5207C60.5499 9.87282 60.3917 10.6115 59.7946 12.4549L60.0547 12.5715C61.276 9.77919 62.5349 8.71388 64.3908 8.71388C66.4819 8.71388 67.4432 10.2078 66.9397 12.5839L67.1644 12.663L67.1602 12.6589Z\"\n fill=\"#191741\"\n />\n <path\n d=\"M111.841 11.4895C108.304 11.7288 107.476 12.9106 107.476 16.712V22.6711H104.307V9.03848H107.488C107.517 9.99976 107.388 10.6885 106.749 12.5174L107.009 12.6339C107.896 10.572 108.926 8.67436 112.066 8.60986L111.841 11.4875V11.4895Z\"\n fill=\"#191741\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_5_959\">\n <rect width=\"200\" height=\"29\" fill=\"white\" />\n </clipPath>\n </defs>\n </svg>\n <p class=\"long-loading-notice long-loading-notice--hidden\">\n Sorry, this is taking an unusually long time.\n </p>\n </div>\n </div>\n <div id=\"app\"></div>\n\n <!-- Loading screen handling -->\n __LOADING_SCREEN_JS__\n\n <!-- Application globals -->\n __APPLICATION_ENVIRONMENT__\n </body>\n</html>\n"
|
|
6
|
+
};
|
|
7
|
+
function generateTemplate(_ref) {
|
|
8
|
+
let _ref$cssImports = _ref.cssImports,
|
|
9
|
+
cssImports = _ref$cssImports === void 0 ? [] : _ref$cssImports,
|
|
10
|
+
_ref$scriptImports = _ref.scriptImports,
|
|
11
|
+
scriptImports = _ref$scriptImports === void 0 ? [] : _ref$scriptImports;
|
|
12
|
+
return htmlDocs.application.replace(new RegExp('__APPLICATION_CSS_IMPORTS__', 'g'), cssImports.join('\n')).replace(new RegExp('__APPLICATION_SCRIPT_IMPORTS__', 'g'), scriptImports.join('\n'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.generateTemplate = generateTemplate;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@commercetools-frontend/mc-html-template",
|
|
3
|
+
"version": "0.0.0-CRAFT-1791-20251006162610",
|
|
4
|
+
"description": "Everything related to render the index.html for a MC application",
|
|
5
|
+
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
9
|
+
"directory": "packages/mc-html-template"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://docs.commercetools.com/merchant-center-customizations",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"frontend",
|
|
15
|
+
"react",
|
|
16
|
+
"toolkit"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"main": "dist/commercetools-frontend-mc-html-template.cjs.js",
|
|
23
|
+
"module": "dist/commercetools-frontend-mc-html-template.esm.js",
|
|
24
|
+
"preconstruct": {
|
|
25
|
+
"entrypoints": [
|
|
26
|
+
"./index.ts",
|
|
27
|
+
"./webpack-html-template.ts"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"webpack-html-template",
|
|
33
|
+
"webpack.js",
|
|
34
|
+
"package.json",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@babel/runtime": "^7.22.15",
|
|
40
|
+
"@babel/runtime-corejs3": "^7.22.15",
|
|
41
|
+
"@commercetools-frontend/application-config": "0.0.0-CRAFT-1791-20251006162610",
|
|
42
|
+
"@commercetools-frontend/constants": "0.0.0-CRAFT-1791-20251006162610",
|
|
43
|
+
"serialize-javascript": "6.0.2",
|
|
44
|
+
"uglify-js": "3.19.3",
|
|
45
|
+
"uglifycss": "0.0.29"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@tsconfig/node22": "^22.0.0",
|
|
49
|
+
"@types/serialize-javascript": "^5.0.2",
|
|
50
|
+
"html-webpack-plugin": "5.6.3",
|
|
51
|
+
"webpack": "5.101.1"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "18.x || 20.x || >=22.0.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from "../../dist/declarations/src/webpack-html-template.js";
|
|
2
|
+
export { default } from "../../dist/declarations/src/webpack-html-template.js";
|
|
3
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1tYy1odG1sLXRlbXBsYXRlLXdlYnBhY2staHRtbC10ZW1wbGF0ZS5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Rpc3QvZGVjbGFyYXRpb25zL3NyYy93ZWJwYWNrLWh0bWwtdGVtcGxhdGUuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
6
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
7
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
8
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
9
|
+
var generateTemplate = require('../../dist/generate-template-13b74c05.cjs.dev.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
14
|
+
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
15
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
16
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
17
|
+
|
|
18
|
+
function webpackHtmlTemplate(templateParams) {
|
|
19
|
+
var _context, _context2, _context3;
|
|
20
|
+
const cssVendorChunks = [];
|
|
21
|
+
const cssAppChunks = [];
|
|
22
|
+
_forEachInstanceProperty__default["default"](_context = templateParams.htmlWebpackPlugin.files.css).call(_context, file => {
|
|
23
|
+
if (_indexOfInstanceProperty__default["default"](file).call(file, 'vendor') === -1) {
|
|
24
|
+
cssAppChunks.push(file);
|
|
25
|
+
} else {
|
|
26
|
+
cssVendorChunks.push(file);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const cssChunks = _mapInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](cssVendorChunks).call(cssVendorChunks, cssAppChunks)).call(_context2, fileName => fileName.replace(/^\//, ''));
|
|
30
|
+
const scriptChunks = _mapInstanceProperty__default["default"](_context3 = templateParams.htmlWebpackPlugin.files.js).call(_context3, fileName =>
|
|
31
|
+
// Trim leading slash, the CDN_URL will ensure to have a trailing slash
|
|
32
|
+
// (see `replaceHtmlPlaceholders`)
|
|
33
|
+
fileName.replace(/^\//, ''));
|
|
34
|
+
const cssImports = _mapInstanceProperty__default["default"](cssChunks).call(cssChunks, chunkPath => `<link href="__CDN_URL__${chunkPath}" rel='stylesheet' type='text/css'>`);
|
|
35
|
+
const scriptImports = _mapInstanceProperty__default["default"](scriptChunks).call(scriptChunks, chunkPath => `<script src="__CDN_URL__${chunkPath}" defer></script>`);
|
|
36
|
+
return generateTemplate.generateTemplate({
|
|
37
|
+
cssImports,
|
|
38
|
+
scriptImports
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports["default"] = webpackHtmlTemplate;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
if (process.env.NODE_ENV === "production") {
|
|
4
|
+
module.exports = require("./commercetools-frontend-mc-html-template-webpack-html-template.cjs.prod.js");
|
|
5
|
+
} else {
|
|
6
|
+
module.exports = require("./commercetools-frontend-mc-html-template-webpack-html-template.cjs.dev.js");
|
|
7
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
6
|
+
var _indexOfInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/index-of');
|
|
7
|
+
var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
|
|
8
|
+
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
9
|
+
var generateTemplate = require('../../dist/generate-template-794a5676.cjs.prod.js');
|
|
10
|
+
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
12
|
+
|
|
13
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
14
|
+
var _indexOfInstanceProperty__default = /*#__PURE__*/_interopDefault(_indexOfInstanceProperty);
|
|
15
|
+
var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
|
|
16
|
+
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
17
|
+
|
|
18
|
+
function webpackHtmlTemplate(templateParams) {
|
|
19
|
+
var _context, _context2, _context3;
|
|
20
|
+
const cssVendorChunks = [];
|
|
21
|
+
const cssAppChunks = [];
|
|
22
|
+
_forEachInstanceProperty__default["default"](_context = templateParams.htmlWebpackPlugin.files.css).call(_context, file => {
|
|
23
|
+
if (_indexOfInstanceProperty__default["default"](file).call(file, 'vendor') === -1) {
|
|
24
|
+
cssAppChunks.push(file);
|
|
25
|
+
} else {
|
|
26
|
+
cssVendorChunks.push(file);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const cssChunks = _mapInstanceProperty__default["default"](_context2 = _concatInstanceProperty__default["default"](cssVendorChunks).call(cssVendorChunks, cssAppChunks)).call(_context2, fileName => fileName.replace(/^\//, ''));
|
|
30
|
+
const scriptChunks = _mapInstanceProperty__default["default"](_context3 = templateParams.htmlWebpackPlugin.files.js).call(_context3, fileName =>
|
|
31
|
+
// Trim leading slash, the CDN_URL will ensure to have a trailing slash
|
|
32
|
+
// (see `replaceHtmlPlaceholders`)
|
|
33
|
+
fileName.replace(/^\//, ''));
|
|
34
|
+
const cssImports = _mapInstanceProperty__default["default"](cssChunks).call(cssChunks, chunkPath => `<link href="__CDN_URL__${chunkPath}" rel='stylesheet' type='text/css'>`);
|
|
35
|
+
const scriptImports = _mapInstanceProperty__default["default"](scriptChunks).call(scriptChunks, chunkPath => `<script src="__CDN_URL__${chunkPath}" defer></script>`);
|
|
36
|
+
return generateTemplate.generateTemplate({
|
|
37
|
+
cssImports,
|
|
38
|
+
scriptImports
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
exports["default"] = webpackHtmlTemplate;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
2
|
+
import _indexOfInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/index-of';
|
|
3
|
+
import _mapInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/map';
|
|
4
|
+
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
5
|
+
import { g as generateTemplate } from '../../dist/generate-template-31dee161.esm.js';
|
|
6
|
+
|
|
7
|
+
function webpackHtmlTemplate(templateParams) {
|
|
8
|
+
var _context, _context2, _context3;
|
|
9
|
+
const cssVendorChunks = [];
|
|
10
|
+
const cssAppChunks = [];
|
|
11
|
+
_forEachInstanceProperty(_context = templateParams.htmlWebpackPlugin.files.css).call(_context, file => {
|
|
12
|
+
if (_indexOfInstanceProperty(file).call(file, 'vendor') === -1) {
|
|
13
|
+
cssAppChunks.push(file);
|
|
14
|
+
} else {
|
|
15
|
+
cssVendorChunks.push(file);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const cssChunks = _mapInstanceProperty(_context2 = _concatInstanceProperty(cssVendorChunks).call(cssVendorChunks, cssAppChunks)).call(_context2, fileName => fileName.replace(/^\//, ''));
|
|
19
|
+
const scriptChunks = _mapInstanceProperty(_context3 = templateParams.htmlWebpackPlugin.files.js).call(_context3, fileName =>
|
|
20
|
+
// Trim leading slash, the CDN_URL will ensure to have a trailing slash
|
|
21
|
+
// (see `replaceHtmlPlaceholders`)
|
|
22
|
+
fileName.replace(/^\//, ''));
|
|
23
|
+
const cssImports = _mapInstanceProperty(cssChunks).call(cssChunks, chunkPath => `<link href="__CDN_URL__${chunkPath}" rel='stylesheet' type='text/css'>`);
|
|
24
|
+
const scriptImports = _mapInstanceProperty(scriptChunks).call(scriptChunks, chunkPath => `<script src="__CDN_URL__${chunkPath}" defer></script>`);
|
|
25
|
+
return generateTemplate({
|
|
26
|
+
cssImports,
|
|
27
|
+
scriptImports
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { webpackHtmlTemplate as default };
|