catalyst-core 0.0.1-beta.13 → 0.0.1-beta.15
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/README.md +3 -2
- package/changelog.md +5 -0
- package/dist/scripts/loadEnvironmentVariables.js +2 -1
- package/dist/sentry.js +2 -0
- package/dist/server/renderer/document/Head.js +1 -1
- package/dist/server/renderer/extract.js +3 -3
- package/dist/server/renderer/handler.js +9 -9
- package/dist/webpack/base.babel.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
|
|
10
10
|
- Overview
|
|
11
11
|
- Installation
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
## Overview
|
|
14
14
|
|
|
15
15
|
Catalyst offers a comprehensive suite of features designed for modern web development. It includes isomorphic rendering for optimal performance, an extendable server with full-stack capabilities, and configurable state management. The framework employs smart prefetching of data and chunks, allows easy configuration of global styles and layouts, and provides SEO optimization at both global and page levels.
|
|
16
|
+
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
18
19
|
**System Requirements**
|
|
@@ -34,7 +35,7 @@ You will see some prompts to configure your application.
|
|
|
34
35
|
cd <name-of-your-project> && npm run start
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
The development server will start at
|
|
38
|
+
The development server will start at `http://localhost:3005`
|
|
38
39
|
|
|
39
40
|
## Documentation
|
|
40
41
|
|
package/changelog.md
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
* @description stores all config.json key value into process.env before server starts.
|
|
3
3
|
*/const loadEnvironmentVariables=()=>{if(validateConfigFile(appConfig)){for(let k in appConfig){// below code provides support for object handling present in config.
|
|
4
4
|
// However, for usage on client the client logic in define plugin needs to be checked and updated
|
|
5
|
-
process.env[k]=typeof appConfig[k]==="object"?JSON.stringify(appConfig[k]):appConfig[k];}}
|
|
5
|
+
process.env[k]=typeof appConfig[k]==="object"?JSON.stringify(appConfig[k]):appConfig[k];}}// Load Sentry configuration if it exists
|
|
6
|
+
try{const sentryConfig=require("@catalyst/template/config/sentry.config.json");process.env.SENTRY_CONFIG=JSON.stringify(sentryConfig);}catch(error){console.warn("Warning: Failed to load sentry.config.json");}};var _default=exports.default=loadEnvironmentVariables;
|
package/dist/sentry.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ErrorBoundary=void 0;exports.addBreadcrumb=addBreadcrumb;exports.captureException=captureException;exports.captureMessage=captureMessage;exports.default=void 0;exports.init=init;var _react=_interopRequireDefault(require("react"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}let sentryInitialized=false;function getSentryInstance(){let instance=null;const isServer=typeof window==="undefined";if(isServer){try{const sentryNodeModule="@sentry/node";// eslint-disable-next-line security/detect-eval-with-expression, no-eval
|
|
2
|
+
instance=eval(`require("${sentryNodeModule}")`);}catch(error){console.warn("Failed to load @sentry/node:",error.message);return null;}}else{try{instance=require("@sentry/react");}catch(error){console.warn("Failed to load @sentry/react:",error.message);return null;}}return instance;}const Sentry=getSentryInstance();function init(){if(sentryInitialized){console.warn("Sentry has already been initialized");return;}let sentryConfig=process.env.SENTRY_CONFIG;if(!sentryConfig){console.warn("Sentry configuration not found, skipping initialization");return;}try{sentryConfig=JSON.parse(sentryConfig);}catch(error){console.warn("Invalid sentry configuration",error);}const isServer=typeof window==="undefined";if(!sentryConfig.dsn){console.warn("Sentry DSN not found in configuration, skipping initialization");return;}try{if(isServer){Sentry.init({dsn:sentryConfig.dsn,tracesSampleRate:sentryConfig.tracesSampleRate||1.0,...sentryConfig.serverOptions});}else{Sentry.init({dsn:sentryConfig.dsn,tracesSampleRate:sentryConfig.tracesSampleRate||1.0,...sentryConfig.clientOptions});}sentryInitialized=true;}catch(error){console.error("Failed to initialize Sentry:",error.message);return;}}function captureException(error,context={}){Sentry.captureException(error,context);}function captureMessage(message,level="info"){Sentry.captureMessage(message,level);}function addBreadcrumb(breadcrumb){Sentry.addBreadcrumb(breadcrumb);}class ErrorBoundary extends _react.default.Component{constructor(props){super(props);this.state={hasError:false};}static getDerivedStateFromError(){return{hasError:true};}componentDidCatch(error,errorInfo){captureException(error,{componentStack:errorInfo.componentStack});}render(){if(this.state.hasError){if(this.props.fallback){return this.props.fallback;}return/*#__PURE__*/(0,_jsxRuntime.jsx)("h1",{children:"Something went wrong."});}return this.props.children;}}exports.ErrorBoundary=ErrorBoundary;var _default=exports.default={init,captureException,captureMessage,addBreadcrumb};
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* @param {array} metaTags - user defined function which returns meta tags in array
|
|
7
7
|
* @param {string} publicAssetPath - public asset path for assets
|
|
8
8
|
* @param {object} children - contains any child elements defined within the component
|
|
9
|
-
*/function Head(props){const{pageCss,preloadJSLinks,metaTags,isBot,publicAssetPath,children}=props;if(children){return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[children,metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{charSet:"utf-8"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"preconnect",href:publicAssetPath}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"dns-prefetch",href:publicAssetPath}),metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}Head.propTypes={isBot:_propTypes.default.bool,preloadJSLinks:_propTypes.default.
|
|
9
|
+
*/function Head(props){const{pageCss,preloadJSLinks,metaTags,isBot,publicAssetPath,children}=props;if(children){return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[children,metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{charSet:"utf-8"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"preconnect",href:publicAssetPath}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"dns-prefetch",href:publicAssetPath}),metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}Head.propTypes={isBot:_propTypes.default.bool,preloadJSLinks:_propTypes.default.array,pageCss:_propTypes.default.string,metaTags:_propTypes.default.array,publicAssetPath:_propTypes.default.string,children:_propTypes.default.node};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheAndFetchAssets=void 0;exports.cacheCSS=cacheCSS;exports.cachePreloadJSLinks=cachePreloadJSLinks;exports.default=_default;var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}function cachePreloadJSLinks(key,data){if(!process.preloadJSLinkCache){process.preloadJSLinkCache={};}let preloadJSLinks=[];if(Array.isArray(data)){try{preloadJSLinks=data.filter(asset=>asset?.props?.as==="script");}catch(error){}}process.preloadJSLinkCache[key]=preloadJSLinks;}/**
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheAndFetchAssets=void 0;exports.cacheCSS=cacheCSS;exports.cachePreloadJSLinks=cachePreloadJSLinks;exports.default=_default;var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}function cachePreloadJSLinks(key,data){if(!process.preloadJSLinkCache){process.preloadJSLinkCache={};}let preloadJSLinks=[];if(Array.isArray(data)){try{preloadJSLinks=data.filter(asset=>asset?.props?.as==="script");}catch(error){logger.error("Error in filtering preloaded JS:"+error);}}process.preloadJSLinkCache[key]=preloadJSLinks;}/**
|
|
2
2
|
* Stores css chunks styles into cache in string format
|
|
3
3
|
* @param {string} key - router path
|
|
4
4
|
* @param {object} data - css elements array extracted through loadable chunk extracter
|
|
5
5
|
*/function cacheCSS(key,data){if(!process.cssCache){process.cssCache={};}let pageCss="";let listOfCachedAssets={};if(Array.isArray(data)){try{if(process.env.NODE_ENV==="production"){data.map(assetChunk=>{const assetPathArr=assetChunk.key.split("/");const assetName=assetPathArr[assetPathArr.length-1];const ext=_path.default.extname(assetName);if(ext===".css"){// if css file has not already been cached, add the content of this CSS file in pageCSS
|
|
6
|
-
if(!listOfCachedAssets[assetName]&&!process.cssCache?.[key]?.listOfCachedAssets?.[assetName]){pageCss+=_fs.default.readFileSync(_path.default.resolve(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`,assetName));listOfCachedAssets[assetName]=true;}}});}}catch(error){}}// if css cache exists for a route and there are some uncached css, add that css to the cache
|
|
6
|
+
if(!listOfCachedAssets[assetName]&&!process.cssCache?.[key]?.listOfCachedAssets?.[assetName]){pageCss+=_fs.default.readFileSync(_path.default.resolve(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`,assetName));listOfCachedAssets[assetName]=true;}}});}}catch(error){logger.error("Error in caching CSS:"+error);}}// if css cache exists for a route and there are some uncached css, add that css to the cache
|
|
7
7
|
// this will run on subsequent hits and will add css of uncached widgets to the cache
|
|
8
8
|
if(process.cssCache[key]){if(pageCss!==""){let existingListOfCachedAssets=process.cssCache[key].listOfCachedAssets;const newPageCSS=process.cssCache[key].pageCss+pageCss;let newListOfCachedAssets={...existingListOfCachedAssets,...listOfCachedAssets};process.cssCache[key]={pageCss:newPageCSS,listOfCachedAssets:newListOfCachedAssets};}}else{// create css cache for a page. This will run on the first hit.
|
|
9
9
|
process.cssCache[key]={pageCss,listOfCachedAssets};}return pageCss;}/**
|
|
@@ -14,7 +14,7 @@ process.cssCache[key]={pageCss,listOfCachedAssets};}return pageCss;}/**
|
|
|
14
14
|
* stores css and js in cache
|
|
15
15
|
* @param {object} res - response object
|
|
16
16
|
* @param {string} route - route path
|
|
17
|
-
*/function _default(res,route){try{const requestPath=route.path;const cachedCss=fetchCachedCSS(requestPath);const cachedPreloadJSLinks=fetchPreloadJSLinkCache(requestPath);if(cachedCss||cachedPreloadJSLinks){res.locals.pageCss=cachedCss;res.locals.preloadJSLinks=cachedPreloadJSLinks;return;}}catch(error){}}const cacheAndFetchAssets=({webExtractor,res,isBot})=>{// For bot first fold css and js would become complete page css and js
|
|
17
|
+
*/function _default(res,route){try{const requestPath=route.path;const cachedCss=fetchCachedCSS(requestPath);const cachedPreloadJSLinks=fetchPreloadJSLinkCache(requestPath);if(cachedCss||cachedPreloadJSLinks){res.locals.pageCss=cachedCss;res.locals.preloadJSLinks=cachedPreloadJSLinks;return;}logger.info({message:"Cache Missed",uri:requestPath});}catch(error){logger.error("Error in extracting assets:"+error);}}const cacheAndFetchAssets=({webExtractor,res,isBot})=>{// For bot first fold css and js would become complete page css and js
|
|
18
18
|
let firstFoldCss="";let firstFoldJS="";const isProd=process.env.NODE_ENV==="production";const{routePath,preloadJSLinks}=res.locals;const linkElements=webExtractor.getLinkElements();// We want to cache/or check for update css on every call
|
|
19
19
|
// We want to extract script tags for every call that will get added to body.
|
|
20
20
|
// Their corresponding preloaded link script tags are already present in head.
|
|
@@ -4,9 +4,9 @@ const getMatchRoutes=(routes,req,res,store,context,fetcherData,basePath="",webEx
|
|
|
4
4
|
const nested=getMatchRoutes(route.children,req,res,store,context,fetcherData,`${basePath}/${path}`,webExtractor);if(nested.length){matches=matches.concat(nested);}}return matches;},[]);};// Preloads chunks required for rendering document
|
|
5
5
|
const getComponent=(store,context,req,fetcherData)=>{return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{id:"app",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactRedux.Provider,{store:store,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server.StaticRouter,{context:context,location:req.originalUrl,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_ServerRouter.default,{store:store,intialData:fetcherData})})})});};// sends document after rendering
|
|
6
6
|
const renderMarkUp=async(errorCode,req,res,metaTags,fetcherData,store,matches,context,webExtractor)=>{const deviceDetails=(0,_userAgentUtil.getUserAgentDetails)(req.headers["user-agent"]||"");const isBot=deviceDetails.googleBot?true:false;let state=store.getState();const jsx=webExtractor.collectChunks(getComponent(store,context,req,fetcherData));const{IS_DEV_COMMAND,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT}=process.env;let publicAssetPath=`${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
7
|
-
if(IS_DEV_COMMAND==="true"){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;}const finalProps={req,res,lang:"en",pageCss:res.locals.pageCss,preloadJSLinks:res.locals.preloadJSLinks,metaTags,isBot,publicAssetPath,jsx,initialState:state,fetcherData};let CompleteDocument=()=>{if((0,_validator.validateCustomDocument)(_document2.default)){return(0,_document2.default)(finalProps);}else{return/*#__PURE__*/(0,_jsxRuntime.jsxs)("html",{lang:finalProps.lang,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Head,{isBot:finalProps.isBot,pageCss:finalProps.pageCss,metaTags:finalProps.metaTags,preloadJSLinks:finalProps.preloadJSLinks,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Body,{jsx:finalProps.jsx,fetcherData:finalProps.fetcherData,initialState:finalProps.initialState})]});}};try{let status=matches.length&&matches[0].match.path==="*"?404:200;res.set({"content-type":"text/html; charset=utf-8"});res.status(status);const{pipe}=(0,_server3.renderToPipeableStream)(/*#__PURE__*/(0,_jsxRuntime.jsx)(CompleteDocument,{}),{onShellReady(){res.setHeader("content-type","text/html");pipe(res);},onAllReady(){const{firstFoldCss,firstFoldJS}=(0,_extract.cacheAndFetchAssets)({webExtractor,res,isBot});res.write(firstFoldCss);res.write(firstFoldJS);res.end();},onError(error){logger.error({message:`\n Error while renderToPipeableStream : ${error.toString()}`});// function defined by user which needs to run if rendering fails
|
|
8
|
-
(0,_validator.safeCall)(_index2.onRenderError);}});}catch(error){logger.error(
|
|
9
|
-
(0,_validator.safeCall)(_index2.onRenderError);}};/**
|
|
7
|
+
if(IS_DEV_COMMAND==="true"){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;}const finalProps={req,res,lang:"en",pageCss:res.locals.pageCss,preloadJSLinks:res.locals.preloadJSLinks,metaTags,isBot,publicAssetPath,jsx,initialState:state,fetcherData};let CompleteDocument=()=>{if((0,_validator.validateCustomDocument)(_document2.default)){return(0,_document2.default)(finalProps);}else{return/*#__PURE__*/(0,_jsxRuntime.jsxs)("html",{lang:finalProps.lang,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Head,{isBot:finalProps.isBot,pageCss:finalProps.pageCss,metaTags:finalProps.metaTags,preloadJSLinks:finalProps.preloadJSLinks,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Body,{jsx:finalProps.jsx,fetcherData:finalProps.fetcherData,initialState:finalProps.initialState})]});}};try{let status=matches.length&&matches[0].match.path==="*"?404:200;res.set({"content-type":"text/html; charset=utf-8"});res.status(status);return new Promise((resolve,reject)=>{const{pipe}=(0,_server3.renderToPipeableStream)(/*#__PURE__*/(0,_jsxRuntime.jsx)(CompleteDocument,{}),{onShellReady(){res.setHeader("content-type","text/html");pipe(res);},onAllReady(){const{firstFoldCss,firstFoldJS}=(0,_extract.cacheAndFetchAssets)({webExtractor,res,isBot});res.write(firstFoldCss);res.write(firstFoldJS);res.end();resolve();},onError(error){logger.error({message:`\n Error while renderToPipeableStream : ${error.toString()}`});// function defined by user which needs to run if rendering fails
|
|
8
|
+
(0,_validator.safeCall)(_index2.onRenderError);reject(error);}});});}catch(error){logger.error({message:`Error in rendering document on server - ${error}`,trace:error.stack,url:req.originalUrl});// function defined by user which needs to run if rendering fails
|
|
9
|
+
(0,_validator.safeCall)(_index2.onRenderError);return Promise.reject(error);}};/**
|
|
10
10
|
* middleware for document handling
|
|
11
11
|
* @param {object} req - request object
|
|
12
12
|
* @param {object} res - response object
|
|
@@ -14,9 +14,9 @@ if(IS_DEV_COMMAND==="true"){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAM
|
|
|
14
14
|
const store=(0,_validator.validateConfigureStore)(createStore)?createStore({},req,res):null;// user defined routes
|
|
15
15
|
const routes=(0,_validator.validateGetRoutes)(_utils.getRoutes)?(0,_utils.getRoutes)():[];// Matches req url with routes
|
|
16
16
|
const matches=getMatchRoutes(routes,req,res,store,context,fetcherData,undefined,webExtractor);const allMatches=(0,_router.matchRoutes)((0,_utils.getRoutes)(),req.baseUrl);let allTags=[];// function defined by user which needs to run after route is matched
|
|
17
|
-
(0,_validator.safeCall)(_index2.onRouteMatch,{req,res,matches})
|
|
18
|
-
_index.default.serverSideFunction({store,req,res})// Executing serverFetcher functions with serverDataFetcher provided by router and returning document
|
|
19
|
-
|
|
20
|
-
(0,_validator.safeCall)(_index2.onFetcherSuccess,{req,res,fetcherData});
|
|
21
|
-
|
|
22
|
-
(0,_validator.safeCall)(_index2.onRequestError,{req,res,error});}}
|
|
17
|
+
(0,_validator.safeCall)(_index2.onRouteMatch,{req,res,matches});if(res.headersSent){return Promise.resolve(res);}try{// Executing app server side function
|
|
18
|
+
await _index.default.serverSideFunction({store,req,res});if(res.headersSent){return Promise.resolve(res);}try{// Executing serverFetcher functions with serverDataFetcher provided by router and returning document
|
|
19
|
+
fetcherData=await(0,_router.serverDataFetcher)({routes:routes,req,res,url:req.originalUrl},{store});if(res.headersSent){return Promise.resolve(res);}allTags=(0,_router.getMetaData)(allMatches,fetcherData);// function defined by user which needs to run after SSR functions are executed
|
|
20
|
+
(0,_validator.safeCall)(_index2.onFetcherSuccess,{req,res,fetcherData});if(res.headersSent){return Promise.resolve(res);}return new Promise((resolve,reject)=>{renderMarkUp(null,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}catch(error){// TODO: serverDataFetcher never throws any error
|
|
21
|
+
logger.error("Error in executing serverFetcher functions: "+error);(0,_validator.safeCall)(_index2.onFetcherError,{req,res,error});if(res.headersSent){return Promise.reject(error);}return new Promise((resolve,reject)=>{renderMarkUp(404,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}}catch(error){logger.error("Error in executing serverSideFunction inside App: "+error);return new Promise((resolve,reject)=>{renderMarkUp(error.status_code,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}}catch(error){logger.error("Error in handling document request: "+error.toString());// function defined by user which needs to run when an error occurs in the handler
|
|
22
|
+
(0,_validator.safeCall)(_index2.onRequestError,{req,res,error});return Promise.reject(error);}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.basePlugins=void 0;var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackBundleAnalyzer=require("webpack-bundle-analyzer");var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _package=require("@catalyst/template/package.json");var _scssParams=require("@catalyst/webpack/scssParams");var _babelConfig=_interopRequireDefault(require("@catalyst/webpack/babel.config.ssr"));var _babelConfig2=_interopRequireDefault(require("@catalyst/webpack/babel.config.client"));var _loadEnvironmentVariables=_interopRequireDefault(require("@catalyst/scripts/loadEnvironmentVariables"));var _config2=require("@catalyst/template/config/config.json");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}(0,_loadEnvironmentVariables.default)();const isDev=process.env.NODE_ENV==="development";const isSSR=!!process.env.SSR||false;const basePlugins=exports.basePlugins=[// **This loads process.env variable during webpack build process
|
|
2
|
-
new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,"BUILD_OUTPUT_PATH","PUBLIC_STATIC_ASSET_PATH","PUBLIC_STATIC_ASSET_URL","src_path","PWD"]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
|
|
2
|
+
new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,"BUILD_OUTPUT_PATH","PUBLIC_STATIC_ASSET_PATH","PUBLIC_STATIC_ASSET_URL","src_path","PWD","SENTRY_CONFIG"]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
|
|
3
3
|
_config2.ANALYZE_BUNDLE&&new _webpackBundleAnalyzer.BundleAnalyzerPlugin({generateStatsFile:_config2.ANALYZE_BUNDLE}),new _webpack.default.IgnorePlugin({resourceRegExp:/^\.\/locale$/,contextRegExp:/moment$/})];const{IS_DEV_COMMAND,PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=isDev?`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/`:`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from local on running devBuild and devServe command
|
|
4
4
|
if(IS_DEV_COMMAND==="true"&&!isDev){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;}var _default=exports.default={context:_path.default.resolve(process.env.src_path),mode:isDev?"development":"production",entry:{app:[_path.default.resolve(process.env.src_path,"./client/index.js")]},output:{path:_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`),filename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",chunkFilename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",publicPath:publicPath},resolve:{fallback:{url:require.resolve("url")},extensions:[".js",".jsx",".scss",".ts",".tsx"],alias:Object.keys(_package._moduleAliases||{}).reduce((moduleEnvMap,alias)=>{moduleEnvMap[alias]=_path.default.join(process.env.src_path,..._package._moduleAliases[alias].split("/"));return moduleEnvMap;},{})},plugins:basePlugins,module:{rules:[{test:/\.jsx$|\.js$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{test:/\.tsx$|\.ts$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{// This loader processes all the .scss files that should be modularized. This should exclude anything inside node_modules and everything inside src/css/base since they should be globally scoped.
|
|
5
5
|
test:/\.scss$/,exclude:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader",options:{modules:{mode:"local",exportOnlyLocals:!isDev&&isSSR,localIdentName:isDev?_config.default.cssModulesIdentifierDev:_config.default.cssModulesIdentifierProd}}},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{// In development mode, client request app.css ,which has all the css in node_modules and src/static/css/base, This is served by webpack-dev-server. However in prod this css is injected in the doc sent from the server and needs to be global, so we don't pass the files through css-loader to be modularized.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catalyst-core",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.15",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Web framework that provides great performance out of the box",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
".": "./dist/index.js",
|
|
29
29
|
"./logger": "./dist/logger.js",
|
|
30
30
|
"./caching": "./dist/caching.js",
|
|
31
|
-
"./router/ClientRouter": "./dist/router/ClientRouter.js"
|
|
31
|
+
"./router/ClientRouter": "./dist/router/ClientRouter.js",
|
|
32
|
+
"./sentry": "./dist/sentry.js"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"lint": "eslint .",
|