Skip to content

Commit

Permalink
chore(widget): use react-app-rewired instead of craco
Browse files Browse the repository at this point in the history
  • Loading branch information
LetItRock committed Oct 2, 2023
1 parent 8785a6d commit 81db15c
Show file tree
Hide file tree
Showing 7 changed files with 547 additions and 893 deletions.
23 changes: 23 additions & 0 deletions apps/widget/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-react",
{
"runtime": "automatic"
}
],
"@babel/preset-env"
],
"plugins": [
"@emotion",
"@babel/plugin-transform-react-display-name",
"@babel/plugin-proposal-optional-chaining",
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
}
10 changes: 10 additions & 0 deletions apps/widget/config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { useBabelRc, override } = require('customize-cra');
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;

function overrideConfig(config, env) {
const plugins = [...config.plugins, /* new BundleAnalyzerPlugin() */];

return { ...config, plugins };
}

module.exports = override(useBabelRc(), overrideConfig);
8 changes: 0 additions & 8 deletions apps/widget/craco.config.js

This file was deleted.

21 changes: 14 additions & 7 deletions apps/widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.20.0-alpha.0",
"private": true,
"scripts": {
"start": "craco start",
"start": "react-app-rewired start",
"start:dev": "cross-env PORT=4500 pnpm start",
"start:cli:local": "pnpm start:shell:test & pnpm start:shell:embed & cross-env PORT=3500 pnpm start",
"start:test": "pnpm start:shell:test & pnpm start:shell:embed & cross-env NODE_ENV=test REACT_APP_API_URL=http://localhost:1336 REACT_APP_WS_URL=http://localhost:1340 PORT=3500 pnpm start",
Expand All @@ -13,9 +13,8 @@
"start:docker": "pnpm build && pnpm start:static:build",
"docker:build": "docker build -f ./Dockerfile -t novu-widget ./../..",
"prebuild": "rimraf build",
"build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 craco build",
"build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 react-app-rewired --max_old_space_size=4096 build",
"precommit": "lint-staged",
"eject": "craco eject",
"lint": "eslint src",
"cypress:run": "cypress run",
"cypress:open": "cypress open",
Expand Down Expand Up @@ -52,8 +51,19 @@
"webfontloader": "^1.6.28"
},
"devDependencies": {
"@craco/craco": "^7.0.0",
"@babel/polyfill": "^7.12.1",
"@babel/preset-env": "^7.13.15",
"@babel/preset-react": "^7.13.13",
"@babel/preset-typescript": "^7.13.0",
"@babel/runtime": "^7.20.13",
"@babel/plugin-proposal-optional-chaining": "^7.20.7",
"@babel/plugin-transform-react-display-name": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.19.6",
"@emotion/babel-plugin": "^11.7.2",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"react-app-rewired": "^2.2.1",
"customize-cra": "^1.0.0",
"@faker-js/faker": "^6.0.0",
"@novu/dal": "^0.20.0-alpha.0",
"@novu/testing": "^0.20.0-alpha.0",
Expand All @@ -62,7 +72,6 @@
"@types/react": "17.0.62",
"@types/react-dom": "17.0.20",
"@types/react-router-dom": "^5.1.7",
"craco-antd": "^1.19.0",
"cross-env": "^7.0.3",
"cypress": "^12.17.2",
"cypress-intellij-reporter": "^0.0.7",
Expand Down Expand Up @@ -109,8 +118,6 @@
"**/@cypress/**",
"**/@storybook/**",
"**/@storybook",
"**/@craco",
"**/@craco/**",
"**/@babel",
"**/@babel/**"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { INovuThemeProvider, INotificationCenterStyles } from '@novu/notifi
import { IMessage, IOrganizationEntity, ButtonTypeEnum } from '@novu/shared';

import { API_URL, WS_URL } from '../../config';
import { isCypress } from '../../utils/browser';

const DEFAULT_FONT_FAMILY = 'inherit';
interface INotificationCenterWidgetProps {
Expand Down Expand Up @@ -102,7 +103,7 @@ export function NotificationCenterWidget(props: INotificationCenterWidgetProps)
}
};

if (process.env.NODE_ENV === 'test') {
if (process.env.NODE_ENV === 'test' || isCypress) {
// eslint-disable-next-line
(window as any).initHandler = handler;
}
Expand Down
2 changes: 2 additions & 0 deletions apps/widget/src/utils/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const isBrowser = () => typeof window !== 'undefined';
export const isCypress = (isBrowser() && (window as any).Cypress) || (isBrowser() && (window as any).parent.Cypress);
Loading

0 comments on commit 81db15c

Please sign in to comment.