catalyst-core 0.0.1-beta.4 → 0.0.1-beta.6

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.
Files changed (92) hide show
  1. package/babel.config.json +1 -0
  2. package/bin/catalyst.js +2 -5
  3. package/changelog.md +14 -22
  4. package/dist/caching.js +1 -0
  5. package/dist/index.js +1 -0
  6. package/dist/logger.js +10 -0
  7. package/dist/router/ClientRouter.js +3 -0
  8. package/dist/router/ServerRouter.js +1 -0
  9. package/dist/router.js +1 -0
  10. package/dist/scripts/build.js +10 -0
  11. package/dist/scripts/centralImport.js +1 -0
  12. package/dist/scripts/checkVersion.js +1 -0
  13. package/dist/scripts/devBuild.js +10 -0
  14. package/dist/scripts/devServe.js +5 -0
  15. package/dist/scripts/loadEnvironmentVariables.js +5 -0
  16. package/dist/scripts/loadScriptsBeforeServerStarts.js +4 -0
  17. package/dist/scripts/registerAliases.js +2 -0
  18. package/dist/scripts/scriptUtils.js +2 -0
  19. package/dist/scripts/serve.js +5 -0
  20. package/dist/scripts/start.js +6 -0
  21. package/dist/scripts/validator.js +1 -0
  22. package/dist/server/expressServer.js +9 -0
  23. package/dist/server/renderer/document/Body.js +14 -0
  24. package/dist/server/renderer/document/Head.js +9 -0
  25. package/dist/server/renderer/document/index.js +1 -0
  26. package/dist/server/renderer/extract.js +21 -0
  27. package/dist/server/renderer/handler.js +17 -0
  28. package/dist/server/renderer/index.js +1 -0
  29. package/dist/server/renderer/render.js +21 -0
  30. package/dist/server/startServer.js +6 -0
  31. package/dist/server/utils/userAgentUtil.js +9 -0
  32. package/dist/server/utils/validator.js +1 -0
  33. package/dist/webpack/babel-plugins/remove-client.plugin.js +5 -0
  34. package/dist/webpack/babel-plugins/remove-ssr.plugin.js +5 -0
  35. package/dist/webpack/babel.config.client.js +1 -0
  36. package/dist/webpack/babel.config.ssr.js +1 -0
  37. package/dist/webpack/base.babel.js +8 -0
  38. package/dist/webpack/development.client.babel.js +4 -0
  39. package/dist/webpack/production.client.babel.js +4 -0
  40. package/dist/webpack/production.ssr.babel.js +4 -0
  41. package/dist/webpack/scssParams.js +9 -0
  42. package/package.json +109 -87
  43. package/.eslintignore +0 -9
  44. package/.eslintrc +0 -92
  45. package/caching.js +0 -16
  46. package/index.js +0 -16
  47. package/logger.js +0 -99
  48. package/router/ClientRouter.js +0 -19
  49. package/router/ServerRouter.js +0 -19
  50. package/router/index.js +0 -32
  51. package/router.js +0 -16
  52. package/scripts/build.js +0 -42
  53. package/scripts/checkVersion.js +0 -5
  54. package/scripts/devBuild.js +0 -42
  55. package/scripts/devServe.js +0 -43
  56. package/scripts/loadEnvironmentVariables.js +0 -24
  57. package/scripts/loadScriptsBeforeServerStarts.js +0 -47
  58. package/scripts/prepare.js +0 -19
  59. package/scripts/registerAliases.js +0 -30
  60. package/scripts/serve.js +0 -43
  61. package/scripts/start.js +0 -35
  62. package/scripts/validator.js +0 -127
  63. package/server/expressServer.js +0 -50
  64. package/server/mainIndex.js +0 -65
  65. package/server/mainServer.js +0 -70
  66. package/server/renderer/document/Body.js +0 -36
  67. package/server/renderer/document/Head.js +0 -43
  68. package/server/renderer/document/index.js +0 -27
  69. package/server/renderer/extract.js +0 -87
  70. package/server/renderer/handler.js +0 -240
  71. package/server/renderer/index.js +0 -12
  72. package/server/renderer/render.js +0 -84
  73. package/server/renderer/userAgentUtil.js +0 -55
  74. package/server/startServer.js +0 -66
  75. package/server/utils/metaTags.js +0 -13
  76. package/server/utils/userAgentUtil.js +0 -51
  77. package/server/utils/validator.js +0 -127
  78. package/tsconfig.json +0 -110
  79. package/webpack/babel-plugins/remove-client.plugin.js +0 -31
  80. package/webpack/babel-plugins/remove-ssr.plugin.js +0 -21
  81. package/webpack/babel.config.client.js +0 -24
  82. package/webpack/babel.config.js +0 -20
  83. package/webpack/babel.config.ssr.js +0 -24
  84. package/webpack/base.babel.js +0 -175
  85. package/webpack/development.client.babel.js +0 -85
  86. package/webpack/plugins/mime-types.js +0 -82
  87. package/webpack/plugins/route-manifest-copy.js +0 -122
  88. package/webpack/plugins/route-manifest-plugin.js +0 -122
  89. package/webpack/plugins/upload-assets-plugin.js +0 -181
  90. package/webpack/production.client.babel.js +0 -78
  91. package/webpack/production.ssr.babel.js +0 -61
  92. package/webpack/scssParams.js +0 -51
@@ -1,82 +0,0 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- m4a: "audio/mp4",
5
- f4a: "audio/mp4",
6
- f4b: "audio/mp4",
7
- oga: "audio/ogg",
8
- ogg: "audio/ogg",
9
- mid: "audio/&",
10
- midi: "audio/&",
11
- mp3: "audio/&",
12
- wav: "audio/&",
13
- js: "application/javascript",
14
- jsonp: "application/javascript",
15
- json: "application/json",
16
- doc: "application/msword",
17
- dot: "application/msword",
18
- bin: "application/octet-stream",
19
- ai: "application/postscript",
20
- pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
21
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
22
- docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
23
- xla: "application/vnd.ms-excel",
24
- xls: "application/vnd.ms-excel",
25
- xlt: "application/vnd.ms-excel",
26
- eot: "application/vnd.ms-fontobject",
27
- pot: "application/vnd.ms-powerpoint",
28
- ppa: "application/vnd.ms-powerpoint",
29
- pps: "application/vnd.ms-powerpoint",
30
- ppt: "application/vnd.ms-powerpoint",
31
- swf: "application/x-shockwave-flash",
32
- atom: "application/xml",
33
- rdf: "application/xml",
34
- rss: "application/xml",
35
- xml: "application/xml",
36
- pdf: "application/&",
37
- rtf: "application/&",
38
- zip: "application/&",
39
- otf: "font/opentype",
40
- ttf: "font/&",
41
- ttc: "font/&",
42
- woff: "font/&",
43
- jpe: "image/jpeg",
44
- jpeg: "image/jpeg",
45
- jpg: "image/jpeg",
46
- svg: "image/svg+xml",
47
- svgz: "image/svg+xml",
48
- psd: "image/vnd.adobe.photoshop",
49
- ico: "image/vnd.microsoft.icon",
50
- bmp: "image/&",
51
- ief: "image/&",
52
- gif: "image/&",
53
- png: "image/&",
54
- tif: "image/&",
55
- tiff: "image/&",
56
- webp: "image/&",
57
- appcache: "text/cache-manifest",
58
- manifest: "text/cache-manifest",
59
- txt: "text/plain",
60
- htc: "text/x-component",
61
- vcf: "text/x-vcard",
62
- css: "text/&",
63
- html: "text/&",
64
- php: "text/&",
65
- vtt: "text/&",
66
- markdown: "text/x-&",
67
- md: "text/x-&",
68
- mp4: "video/mp4",
69
- m4v: "video/mp4",
70
- f4v: "video/mp4",
71
- f4p: "video/mp4",
72
- ogv: "video/ogg",
73
- mov: "video/quicktime",
74
- qt: "video/quicktime",
75
- avi: "video/&",
76
- mpg: "video/&",
77
- vdo: "video/&",
78
- viv: "video/&",
79
- vivo: "video/&",
80
- webm: "video/&",
81
- flv: "video/x-&"
82
- };
@@ -1,122 +0,0 @@
1
- "use strict";
2
-
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- const NAME = "route-manifest-plugin";
9
- const fs = require("fs");
10
- const path = require("path");
11
- const acornLoose = require("acorn-loose");
12
- const zlib = require("zlib");
13
- const generateMappingToOrigin = (pathToRoutesFile, routesVariableName) => {
14
- const fileContent = fs.readFileSync(path.resolve(pathToRoutesFile), "utf-8");
15
- const ast = acornLoose.parse(fileContent, {
16
- ecmaVersion: 2020
17
- });
18
- const routes = [];
19
- const componentMapping = {};
20
- const getValue = valueObj => {
21
- switch (valueObj.type) {
22
- case "Literal":
23
- return valueObj.value;
24
- case "Identifier":
25
- return valueObj.name;
26
- default:
27
- return "";
28
- }
29
- };
30
- ast.body.forEach(declarationBlock => {
31
- declarationBlock?.declarations?.forEach(variableDeclaration => {
32
- if (variableDeclaration?.id?.name === routesVariableName) {
33
- const objectExpression = variableDeclaration?.init?.elements;
34
- objectExpression.forEach(obj => {
35
- const route = {};
36
- obj?.properties.forEach(property => {
37
- if (property) route[property.key.name] = getValue(property.value);
38
- });
39
- routes.push(route);
40
- });
41
- }
42
- if (variableDeclaration?.init?.type === "CallExpression" && variableDeclaration?.init?.callee?.name === "loadable") {
43
- const componentName = variableDeclaration?.id?.name;
44
- const importArgument = variableDeclaration?.init?.arguments?.[0]; // import is first argument in loadable;
45
- componentMapping[componentName] = importArgument?.body?.source?.value;
46
- }
47
- });
48
- });
49
- const mappedRoutes = routes.map(route => _objectSpread(_objectSpread({}, route), {}, {
50
- origin: componentMapping[route.component] || ""
51
- }));
52
- return mappedRoutes;
53
- };
54
- const RoutesManifestPlugin = function (options) {
55
- this.options = options;
56
- };
57
- RoutesManifestPlugin.prototype.run = function (bundle, options) {
58
- const {
59
- pathToRoutesFile,
60
- routesVariableName
61
- } = options;
62
- const mappedRoutes = generateMappingToOrigin(pathToRoutesFile, routesVariableName);
63
- const {
64
- publicPath,
65
- chunks
66
- } = bundle.getStats().toJson();
67
- const originToChunksMapping = {};
68
- const originToChildrenMapping = {};
69
- chunks.forEach(chunk => {
70
- chunk.origins.forEach(origin => {
71
- originToChunksMapping[origin.request] = [...(originToChunksMapping[origin.request] || []), ...chunk.files.map(file => `${publicPath}${file}`)];
72
- chunk.children.forEach(childId => {
73
- const chunk = chunks.find(chunk => chunk.id === childId);
74
- originToChildrenMapping[origin.request] = [...(originToChildrenMapping[origin.request] || []), ...chunk.files.map(file => `${publicPath}${file}`)];
75
- });
76
- });
77
- });
78
- mappedRoutes.forEach(mappedRoute => {
79
- mappedRoute.chunks = [...new Set(originToChunksMapping[mappedRoute.origin])];
80
- mappedRoute.children = [...new Set(originToChildrenMapping[mappedRoute.origin])];
81
- });
82
- return mappedRoutes;
83
- };
84
- RoutesManifestPlugin.prototype.apply = function (compiler) {
85
- if (compiler.hooks !== void 0) {
86
- compiler.hooks.emit.tap(NAME, compilation => {
87
- const assetsMappingJson = this.run(compilation, this.options);
88
- const stringifiedAssetsMappingJson = JSON.stringify(assetsMappingJson);
89
- const compressedGzip = zlib.gzipSync(stringifiedAssetsMappingJson);
90
- const compressedBrotli = zlib.brotliCompressSync(stringifiedAssetsMappingJson);
91
- compilation.assets["route-manifest.json.gz"] = {
92
- source: function () {
93
- return compressedGzip;
94
- },
95
- size: function () {
96
- return compressedGzip.length;
97
- }
98
- };
99
- compilation.assets["route-manifest.json.br"] = {
100
- source: function () {
101
- return compressedBrotli;
102
- },
103
- size: function () {
104
- return compressedBrotli.length;
105
- }
106
- };
107
- compilation.assets["route-manifest.json"] = {
108
- source: function () {
109
- return stringifiedAssetsMappingJson;
110
- },
111
- size: function () {
112
- return stringifiedAssetsMappingJson.length;
113
- }
114
- };
115
- });
116
- } else {
117
- compiler.plugin("emit", bundle => {
118
- this.run(bundle, this.options);
119
- });
120
- }
121
- };
122
- module.exports = RoutesManifestPlugin;
@@ -1,122 +0,0 @@
1
- "use strict";
2
-
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
- const NAME = "route-manifest-plugin";
9
- const fs = require("fs");
10
- const path = require("path");
11
- const acornLoose = require("acorn-loose");
12
- const zlib = require("zlib");
13
- const generateMappingToOrigin = (pathToRoutesFile, routesVariableName) => {
14
- const fileContent = fs.readFileSync(path.resolve(pathToRoutesFile), "utf-8");
15
- const ast = acornLoose.parse(fileContent, {
16
- ecmaVersion: 2020
17
- });
18
- const routes = [];
19
- const componentMapping = {};
20
- const getValue = valueObj => {
21
- switch (valueObj.type) {
22
- case "Literal":
23
- return valueObj.value;
24
- case "Identifier":
25
- return valueObj.name;
26
- default:
27
- return "";
28
- }
29
- };
30
- ast.body.forEach(declarationBlock => {
31
- declarationBlock?.declarations?.forEach(variableDeclaration => {
32
- if (variableDeclaration?.id?.name === routesVariableName) {
33
- const objectExpression = variableDeclaration?.init?.elements;
34
- objectExpression.forEach(obj => {
35
- const route = {};
36
- obj?.properties.forEach(property => {
37
- if (property) route[property.key.name] = getValue(property.value);
38
- });
39
- routes.push(route);
40
- });
41
- }
42
- if (variableDeclaration?.init?.type === "CallExpression" && variableDeclaration?.init?.callee?.name === "loadable") {
43
- const componentName = variableDeclaration?.id?.name;
44
- const importArgument = variableDeclaration?.init?.arguments?.[0]; // import is first argument in loadable;
45
- componentMapping[componentName] = importArgument?.body?.source?.value;
46
- }
47
- });
48
- });
49
- const mappedRoutes = routes.map(route => _objectSpread(_objectSpread({}, route), {}, {
50
- origin: componentMapping[route.component] || ""
51
- }));
52
- return mappedRoutes;
53
- };
54
- const RoutesManifestPlugin = function (options) {
55
- this.options = options;
56
- };
57
- RoutesManifestPlugin.prototype.run = function (bundle, options) {
58
- const {
59
- pathToRoutesFile,
60
- routesVariableName
61
- } = options;
62
- const mappedRoutes = generateMappingToOrigin(pathToRoutesFile, routesVariableName);
63
- const {
64
- publicPath,
65
- chunks
66
- } = bundle.getStats().toJson();
67
- const originToChunksMapping = {};
68
- const originToChildrenMapping = {};
69
- chunks.forEach(chunk => {
70
- chunk.origins.forEach(origin => {
71
- originToChunksMapping[origin.request] = [...(originToChunksMapping[origin.request] || []), ...chunk.files.map(file => `${publicPath}${file}`)];
72
- chunk.children.forEach(childId => {
73
- const chunk = chunks.find(chunk => chunk.id === childId);
74
- originToChildrenMapping[origin.request] = [...(originToChildrenMapping[origin.request] || []), ...chunk.files.map(file => `${publicPath}${file}`)];
75
- });
76
- });
77
- });
78
- mappedRoutes.forEach(mappedRoute => {
79
- mappedRoute.chunks = [...new Set(originToChunksMapping[mappedRoute.origin])];
80
- mappedRoute.children = [...new Set(originToChildrenMapping[mappedRoute.origin])];
81
- });
82
- return mappedRoutes;
83
- };
84
- RoutesManifestPlugin.prototype.apply = function (compiler) {
85
- if (compiler.hooks !== void 0) {
86
- compiler.hooks.emit.tap(NAME, compilation => {
87
- const assetsMappingJson = this.run(compilation, this.options);
88
- const stringifiedAssetsMappingJson = JSON.stringify(assetsMappingJson);
89
- const compressedGzip = zlib.gzipSync(stringifiedAssetsMappingJson);
90
- const compressedBrotli = zlib.brotliCompressSync(stringifiedAssetsMappingJson);
91
- compilation.assets["route-manifest.json.gz"] = {
92
- source: function () {
93
- return compressedGzip;
94
- },
95
- size: function () {
96
- return compressedGzip.length;
97
- }
98
- };
99
- compilation.assets["route-manifest.json.br"] = {
100
- source: function () {
101
- return compressedBrotli;
102
- },
103
- size: function () {
104
- return compressedBrotli.length;
105
- }
106
- };
107
- compilation.assets["route-manifest.json"] = {
108
- source: function () {
109
- return stringifiedAssetsMappingJson;
110
- },
111
- size: function () {
112
- return stringifiedAssetsMappingJson.length;
113
- }
114
- };
115
- });
116
- } else {
117
- compiler.plugin("emit", bundle => {
118
- this.run(bundle, this.options);
119
- });
120
- }
121
- };
122
- module.exports = RoutesManifestPlugin;
@@ -1,181 +0,0 @@
1
- "use strict";
2
-
3
- const fs = require("fs"),
4
- AWS = require("aws-sdk"),
5
- path = require("path"),
6
- mimeTypeByExtension = require("./mime-types");
7
- const getContentType = filePath => {
8
- const extname = path.extname(filePath);
9
- const pathChunks = filePath.split(".");
10
- const chunkLength = pathChunks.length;
11
- const extension = extname === ".br" || extname === ".gz" ? pathChunks[chunkLength - 2] : pathChunks[chunkLength - 1];
12
- switch (extension) {
13
- case "svg":
14
- return "image/svg+xml";
15
- case "css":
16
- return "text/css";
17
- default:
18
- return mimeTypeByExtension[extension] || "text/plain";
19
- }
20
- };
21
- /* eslint-disable */
22
- const uploadImages = async ({
23
- assetsDir,
24
- s3BucketName,
25
- s3Folder,
26
- exclude
27
- }) => {
28
- // picks aws keys directly from the ec2 instance
29
- const s3 = new AWS.S3({
30
- signatureVersion: "v4"
31
- }),
32
- // cloudfront = new AWS.CloudFront(),
33
- s3PathForUpload = relativeFilePath => `${s3Folder}/${relativeFilePath}`,
34
- allFilesIn = function (dir, filelist, parent) {
35
- const files = fs.readdirSync(dir);
36
- filelist = filelist || [];
37
- files.forEach(function (file) {
38
- if (fs.statSync(dir + file).isDirectory()) {
39
- filelist = allFilesIn(dir + file + "/", filelist, (parent ? parent + "/" : "") + file);
40
- } else {
41
- filelist.push(parent ? parent + "/" + file : file);
42
- }
43
- });
44
- return filelist;
45
- },
46
- uploadFile = (filePath, targetPath) => {
47
- //eslint-disable-next-line
48
- fs.readFile(filePath, (error, fileContent) => {
49
- if (error) {
50
- throw error;
51
- }
52
- if (!exclude.test(filePath)) {
53
- const fileStream = fs.createReadStream(filePath);
54
- fileStream.on("error", function (err) {
55
- console.dir({
56
- service_name: "pwa-dweb-node-server",
57
- loglevel: "error",
58
- version: "v2",
59
- message: "File Error",
60
- traceback: err
61
- });
62
- });
63
- s3.upload({
64
- Bucket: s3BucketName,
65
- Key: targetPath,
66
- Body: fileStream,
67
- ContentType: getContentType(filePath),
68
- ACL: "public-read",
69
- XRobotsTag: "noindex, nofollow",
70
- CacheControl: "max-age=31536000"
71
- }, (err, data) => {
72
- if (err) {
73
- console.log(`Failed uploading : '${filePath}'!`, err);
74
- }
75
- });
76
- }
77
- });
78
- },
79
- emptyBucket = async () => {
80
- /* eslint-disable-line */
81
- /* eslint-disable-line */
82
- const dir = "pwa-app/staging";
83
- var params = {
84
- Bucket: s3BucketName,
85
- Prefix: dir
86
- };
87
- const listedObjects = await s3.listObjectsV2(params).promise();
88
- console.dir({
89
- service_name: "pwa-dweb-node-server",
90
- loglevel: "info",
91
- version: "v2",
92
- message: `\n listed objects ${listedObjects}`
93
- });
94
- if (listedObjects.Contents.length === 0) {
95
- console.dir({
96
- service_name: "pwa-dweb-node-server",
97
- loglevel: "info",
98
- version: "v2",
99
- message: " No files on S3 "
100
- });
101
- return;
102
- }
103
- const deleteParams = {
104
- Bucket: s3BucketName,
105
- Delete: {
106
- Objects: []
107
- }
108
- };
109
- listedObjects.Contents.forEach(({
110
- Key
111
- }) => {
112
- deleteParams.Delete.Objects.push({
113
- Key
114
- });
115
- });
116
- console.dir({
117
- service_name: "pwa-dweb-node-server",
118
- loglevel: "info",
119
- version: "v2",
120
- message: `Removing ${deleteParams.Delete.Objects.length} items from ${dir}`
121
- });
122
- await s3.deleteObjects(deleteParams).promise();
123
- if (listedObjects.IsTruncated) await emptyBucket();
124
- },
125
- /* following code is not being used */
126
- // inValidateCache = () => {
127
- // /* eslint-disable-line */
128
- // /* eslint-disable-line */
129
- // let randomString = Math.random().toString(36).substring(7)
130
-
131
- // const params = {
132
- // DistributionId: process.env.DISTRIBUTION_ID,
133
- // /* required */
134
- // InvalidationBatch: {
135
- // /* required */
136
- // CallerReference: randomString,
137
- // /* required */
138
- // Paths: {
139
- // /* required */
140
- // Quantity: 1,
141
- // /* required */
142
- // Items: [`/pwa-app/${process.env.BUILD_ENV}/*`],
143
- // },
144
- // },
145
- // }
146
- // cloudfront.createInvalidation(params, function (err, data) {
147
- // if (err) console.log(err, err.stack)
148
- // // an error occurred
149
- // else console.log("Cache Invalidation Successful", data) // successful response
150
- // })
151
- // },
152
- relativePaths = allFilesIn(assetsDir, []);
153
-
154
- // Remove files from bucket
155
- // await emptyBucket(`${process.env.S3_FOLDER}/${process.env.BUILD_ENV}`);
156
- // await emptyBucket();
157
- relativePaths.forEach(relativePath => {
158
- const fullPathToFile = path.join(assetsDir, relativePath),
159
- s3FolderPath = s3PathForUpload(relativePath);
160
- if (!fs.lstatSync(fullPathToFile).isDirectory()) {
161
- uploadFile(fullPathToFile, s3FolderPath);
162
- }
163
- });
164
-
165
- // console.log("==============================================");
166
- // console.log("==========Starting cache invalidation=========");
167
- // console.log("==============================================");
168
-
169
- // if (process.env.BUILD_ENV === "production") inValidateCache();
170
- };
171
-
172
- const UploadAssetsPlugin = function (options) {
173
- this.options = options;
174
- };
175
- UploadAssetsPlugin.prototype.apply = function (compiler) {
176
- compiler.hooks.done.tap("UploadAssetsPlugin", () => {
177
- uploadImages(this.options);
178
- });
179
- };
180
- module.exports = UploadAssetsPlugin;
181
- /* eslint-enable */
@@ -1,78 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _base = _interopRequireDefault(require("./base.babel"));
8
- var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
9
- var _path = _interopRequireDefault(require("path"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const {
12
- mergeWithCustomize,
13
- customizeArray,
14
- customizeObject
15
- } = require("webpack-merge");
16
- const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
17
- const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
18
- const clientConfig = mergeWithCustomize({
19
- customizeArray: customizeArray({
20
- entry: "prepend",
21
- plugins: "append",
22
- module: "prepend"
23
- }),
24
- customizeObject: customizeObject({
25
- entry: "prepend",
26
- plugins: "append",
27
- module: "prepend"
28
- })
29
- })(_base.default, {
30
- mode: "production",
31
- optimization: {
32
- runtimeChunk: "single",
33
- moduleIds: "deterministic",
34
- splitChunks: {
35
- cacheGroups: {
36
- commonVendor: {
37
- chunks: "all",
38
- test: /[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,
39
- name: "commonVendor",
40
- minSize: 400000,
41
- maxSize: 400000
42
- },
43
- utilityVendor: {
44
- maxInitialRequests: Infinity,
45
- chunks: "all",
46
- // minSize: 0, // Enable to replicate stand alone chunking for all packages
47
- reuseExistingChunk: true,
48
- // Disable to replicate stand alone chunking for all packages
49
- minRemainingSize: 1000,
50
- // Disable to replicate stand alone chunking for all packages
51
- minSize: 1000,
52
- maxSize: 120000,
53
- test: /[\\/]node_modules[\\/]/,
54
- name(module) {
55
- const moduleFileName = module.identifier().split("/").reverse().slice(0, 3).reduce((item, current) => {
56
- item = current + "." + item;
57
- return item;
58
- }, []);
59
- return `npm.${moduleFileName}`;
60
- }
61
- }
62
- },
63
- chunks: "all",
64
- name(module) {
65
- const moduleFileName = module.identifier().split("/").reverse().slice(0, 3).reduce((item, current) => {
66
- item = current + "." + item;
67
- return item;
68
- }, []);
69
- return `npm.${moduleFileName}`;
70
- }
71
- }
72
- },
73
- plugins: [new _miniCssExtractPlugin.default({
74
- filename: catalystConfig.cssChunkFileName,
75
- ignoreOrder: true
76
- }), ...plugins.clientPlugins]
77
- });
78
- var _default = exports.default = clientConfig;
@@ -1,61 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _webpackNodeExternals = _interopRequireDefault(require("webpack-node-externals"));
8
- var _path = _interopRequireDefault(require("path"));
9
- var _base = _interopRequireDefault(require("./base.babel"));
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const {
12
- mergeWithCustomize,
13
- customizeArray,
14
- customizeObject
15
- } = require("webpack-merge");
16
- const rootWorkspacePath = require("app-root-path");
17
- const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
18
- const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
19
- const ssrConfig = mergeWithCustomize({
20
- customizeArray: customizeArray({
21
- entry: "replace",
22
- optimization: "replace",
23
- plugins: "prepend"
24
- }),
25
- customizeObject: customizeObject({
26
- entry: "replace",
27
- optimization: "replace",
28
- plugins: "prepend"
29
- })
30
- })(_base.default, {
31
- mode: "production",
32
- optimization: {
33
- splitChunks: {
34
- chunks: "all",
35
- minSize: 10000000,
36
- name: false
37
- }
38
- },
39
- plugins: [...plugins.ssrPlugins],
40
- target: "node",
41
- entry: {
42
- handler: _path.default.resolve(__dirname, "..", "./server/renderer/handler.js")
43
- },
44
- externals: [
45
- // images are handled by isomorphic webpack.
46
- // html files are required directly
47
- /\.(html|png|gif|jpg)$/,
48
- // treat all node modules as external to keep this bundle small
49
- (0, _webpackNodeExternals.default)({
50
- modulesDir: _path.default.resolve(process.env.src_path, "./node_modules")
51
- }), (0, _webpackNodeExternals.default)({
52
- modulesDir: _path.default.join(rootWorkspacePath.path, "./node_modules")
53
- })],
54
- output: {
55
- path: _path.default.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH, "/renderer"),
56
- chunkFilename: catalystConfig.chunkFileNameProd,
57
- filename: "handler.js",
58
- libraryTarget: "commonjs"
59
- }
60
- });
61
- var _default = exports.default = ssrConfig;