@openedx/frontend-base 1.0.0-alpha.0
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 +661 -0
- package/README.md +112 -0
- package/config/babel/babel.config.js +28 -0
- package/config/config-helpers/createConfig.js +13 -0
- package/config/config-helpers/createLintConfig.js +16 -0
- package/config/config-helpers/getBaseConfig.js +12 -0
- package/config/defaultConfigPaths.js +35 -0
- package/config/eslint/base.eslint.config.js +113 -0
- package/config/index.js +12 -0
- package/config/jest/jest.config.js +30 -0
- package/config/tsconfig.json +32 -0
- package/config/types.js +25 -0
- package/config/webpack/common-config/all/getCodeRules.js +52 -0
- package/config/webpack/common-config/all/getFileLoaderRules.js +26 -0
- package/config/webpack/common-config/all/getIgnoreWarnings.js +14 -0
- package/config/webpack/common-config/all/getImageMinimizer.js +25 -0
- package/config/webpack/common-config/all/getStylesheetRule.js +112 -0
- package/config/webpack/common-config/dev/getDevServer.js +38 -0
- package/config/webpack/common-config/index.js +18 -0
- package/config/webpack/common-config/site/getHtmlWebpackPlugin.js +16 -0
- package/config/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +91 -0
- package/config/webpack/plugins/html-webpack-new-relic-plugin/index.js +7 -0
- package/config/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +3 -0
- package/config/webpack/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.js +108 -0
- package/config/webpack/plugins/paragon-webpack-plugin/index.js +7 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/assetUtils.js +64 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/htmlUtils.js +53 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/index.js +9 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/paragonStylesheetUtils.js +114 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/scriptUtils.js +146 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/stylesheetUtils.js +126 -0
- package/config/webpack/plugins/paragon-webpack-plugin/utils/tagUtils.js +57 -0
- package/config/webpack/types.js +2 -0
- package/config/webpack/utils/getLocalAliases.js +65 -0
- package/config/webpack/utils/getPublicPath.js +6 -0
- package/config/webpack/utils/getResolvedSiteConfigPath.js +32 -0
- package/config/webpack/utils/paragonUtils.js +138 -0
- package/config/webpack/webpack.config.build.js +80 -0
- package/config/webpack/webpack.config.dev.js +76 -0
- package/config/webpack/webpack.config.dev.shell.js +110 -0
- package/eslint.config.js +18 -0
- package/frontend-base.d.ts +8 -0
- package/index.ts +7 -0
- package/jest.config.js +7 -0
- package/openedx-frontend-base.tgz +0 -0
- package/package.json +149 -0
- package/runtime/analytics/MockAnalyticsService.js +71 -0
- package/runtime/analytics/SegmentAnalyticsService.js +243 -0
- package/runtime/analytics/index.ts +12 -0
- package/runtime/analytics/interface.js +145 -0
- package/runtime/auth/AxiosCsrfTokenService.js +60 -0
- package/runtime/auth/AxiosJwtAuthService.js +363 -0
- package/runtime/auth/AxiosJwtTokenService.js +134 -0
- package/runtime/auth/LocalForageCache.js +76 -0
- package/runtime/auth/MockAuthService.js +278 -0
- package/runtime/auth/index.ts +19 -0
- package/runtime/auth/interceptors/createCsrfTokenProviderInterceptor.js +36 -0
- package/runtime/auth/interceptors/createJwtTokenProviderInterceptor.js +37 -0
- package/runtime/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js +20 -0
- package/runtime/auth/interceptors/createRetryInterceptor.js +74 -0
- package/runtime/auth/interface.js +309 -0
- package/runtime/auth/utils.js +105 -0
- package/runtime/babel.config.js +3 -0
- package/runtime/config/index.ts +295 -0
- package/runtime/constants.ts +68 -0
- package/runtime/i18n/index.js +118 -0
- package/runtime/i18n/injectIntlWithShim.jsx +48 -0
- package/runtime/i18n/lib.ts +272 -0
- package/runtime/index.ts +134 -0
- package/runtime/initialize.js +352 -0
- package/runtime/jest.config.js +32 -0
- package/runtime/logging/MockLoggingService.js +31 -0
- package/runtime/logging/NewRelicLoggingService.js +184 -0
- package/runtime/logging/index.ts +9 -0
- package/runtime/logging/interface.js +109 -0
- package/runtime/logging/types.ts +4 -0
- package/runtime/react/AuthenticatedPageRoute.jsx +43 -0
- package/runtime/react/CombinedAppProvider.tsx +46 -0
- package/runtime/react/CurrentAppContext.tsx +25 -0
- package/runtime/react/CurrentAppProvider.tsx +46 -0
- package/runtime/react/Divider.tsx +5 -0
- package/runtime/react/ErrorBoundary.jsx +47 -0
- package/runtime/react/ErrorPage.jsx +72 -0
- package/runtime/react/LoginRedirect.jsx +16 -0
- package/runtime/react/PageWrap.jsx +24 -0
- package/runtime/react/SiteContext.tsx +32 -0
- package/runtime/react/SiteProvider.tsx +78 -0
- package/runtime/react/hooks.ts +106 -0
- package/runtime/react/index.ts +19 -0
- package/runtime/routing/index.ts +1 -0
- package/runtime/routing/utils.ts +34 -0
- package/runtime/scripts/GoogleAnalyticsLoader.ts +59 -0
- package/runtime/scripts/index.ts +1 -0
- package/runtime/setupTest.js +49 -0
- package/runtime/slots/Slot.tsx +32 -0
- package/runtime/slots/SlotContext.tsx +8 -0
- package/runtime/slots/hooks.ts +35 -0
- package/runtime/slots/index.ts +7 -0
- package/runtime/slots/layout/DefaultSlotLayout.tsx +9 -0
- package/runtime/slots/layout/hooks.ts +65 -0
- package/runtime/slots/layout/index.ts +5 -0
- package/runtime/slots/layout/types.ts +45 -0
- package/runtime/slots/layout/utils.ts +14 -0
- package/runtime/slots/types.ts +23 -0
- package/runtime/slots/utils.ts +59 -0
- package/runtime/slots/widget/WidgetContext.tsx +9 -0
- package/runtime/slots/widget/WidgetProvider.tsx +30 -0
- package/runtime/slots/widget/hooks.ts +105 -0
- package/runtime/slots/widget/iframe/IFrameContentWrapper.messages.tsx +16 -0
- package/runtime/slots/widget/iframe/IFrameContentWrapper.tsx +84 -0
- package/runtime/slots/widget/iframe/IFrameWidget.tsx +59 -0
- package/runtime/slots/widget/iframe/constants.ts +19 -0
- package/runtime/slots/widget/iframe/hooks.ts +179 -0
- package/runtime/slots/widget/iframe/index.ts +6 -0
- package/runtime/slots/widget/iframe/types.ts +7 -0
- package/runtime/slots/widget/index.ts +6 -0
- package/runtime/slots/widget/types.ts +134 -0
- package/runtime/slots/widget/utils.tsx +201 -0
- package/runtime/subscriptions.ts +60 -0
- package/runtime/testing/index.ts +9 -0
- package/runtime/testing/initializeMockApp.ts +81 -0
- package/runtime/testing/mockMessages.ts +23 -0
- package/runtime/utils.js +178 -0
- package/shell/DefaultLayout.tsx +18 -0
- package/shell/DefaultMain.tsx +7 -0
- package/shell/Logo.tsx +28 -0
- package/shell/Shell.messages.ts +61 -0
- package/shell/Shell.tsx +18 -0
- package/shell/app.scss +149 -0
- package/shell/app.ts +24 -0
- package/shell/babel.config.js +3 -0
- package/shell/dev/devFooter/app.tsx +43 -0
- package/shell/dev/devFooter/index.ts +1 -0
- package/shell/dev/devHeader/BarContext.tsx +13 -0
- package/shell/dev/devHeader/BarLink.tsx +16 -0
- package/shell/dev/devHeader/BarProvider.tsx +25 -0
- package/shell/dev/devHeader/CoursesLink.tsx +16 -0
- package/shell/dev/devHeader/FooContext.tsx +13 -0
- package/shell/dev/devHeader/FooLink.tsx +16 -0
- package/shell/dev/devHeader/FooProvider.tsx +25 -0
- package/shell/dev/devHeader/app.tsx +53 -0
- package/shell/dev/devHeader/index.ts +1 -0
- package/shell/dev/devHeader/providers.tsx +11 -0
- package/shell/dev/devHome/HomePage.tsx +28 -0
- package/shell/dev/devHome/app.ts +18 -0
- package/shell/dev/devHome/i18n/index.ts +27 -0
- package/shell/dev/devHome/index.ts +1 -0
- package/shell/dev/devHome/messages.ts +11 -0
- package/shell/dev/devUser/app.tsx +24 -0
- package/shell/dev/devUser/index.ts +1 -0
- package/shell/dev/index.ts +5 -0
- package/shell/dev/slotShowcase/HorizontalSlotLayout.tsx +11 -0
- package/shell/dev/slotShowcase/LayoutWithOptions.tsx +17 -0
- package/shell/dev/slotShowcase/SlotShowcasePage.tsx +66 -0
- package/shell/dev/slotShowcase/WidgetWithOptions.tsx +11 -0
- package/shell/dev/slotShowcase/app.tsx +373 -0
- package/shell/dev/slotShowcase/index.ts +1 -0
- package/shell/footer/CenterLinks.tsx +11 -0
- package/shell/footer/CopyrightNotice.tsx +36 -0
- package/shell/footer/Footer.tsx +34 -0
- package/shell/footer/LabeledLinkColumn.tsx +19 -0
- package/shell/footer/LanguageMenu.tsx +35 -0
- package/shell/footer/LanguageMenuItem.tsx +23 -0
- package/shell/footer/LeftLinks.tsx +11 -0
- package/shell/footer/LegalNotices.tsx +17 -0
- package/shell/footer/PoweredBy.tsx +17 -0
- package/shell/footer/RevealLinks.tsx +43 -0
- package/shell/footer/RightLinks.tsx +11 -0
- package/shell/footer/app.tsx +73 -0
- package/shell/footer/data/api.ts +48 -0
- package/shell/footer/index.ts +2 -0
- package/shell/header/AuthenticatedMenu.tsx +32 -0
- package/shell/header/Header.tsx +17 -0
- package/shell/header/anonymous-menu/AnonymousMenu.tsx +14 -0
- package/shell/header/anonymous-menu/LoginButton.tsx +14 -0
- package/shell/header/anonymous-menu/RegisterButton.tsx +15 -0
- package/shell/header/app.tsx +142 -0
- package/shell/header/desktop/DesktopLayout.tsx +22 -0
- package/shell/header/desktop/PrimaryNavLinks.tsx +10 -0
- package/shell/header/desktop/SecondaryNavLinks.tsx +10 -0
- package/shell/header/index.ts +2 -0
- package/shell/header/mobile/MobileLayout.tsx +47 -0
- package/shell/header/mobile/MobileNavLinks.tsx +10 -0
- package/shell/i18n/index.ts +25 -0
- package/shell/index.ts +7 -0
- package/shell/jest.config.js +30 -0
- package/shell/menus/LinkMenuItem.tsx +64 -0
- package/shell/menus/NavDropdownMenuSlot.tsx +29 -0
- package/shell/menus/ProfileLinkMenuItem.tsx +33 -0
- package/shell/menus/data/utils.ts +19 -0
- package/shell/public/index.html +10 -0
- package/shell/router/createRouter.ts +17 -0
- package/shell/router/getAppRoutes.ts +21 -0
- package/shell/setupTest.js +48 -0
- package/shell/site.config.dev.tsx +49 -0
- package/shell/site.tsx +41 -0
- package/test-site/app.d.ts +15 -0
- package/test-site/dist/176.436443549ebb858db483.js +2 -0
- package/test-site/dist/176.436443549ebb858db483.js.map +1 -0
- package/test-site/dist/362.536eff787d2380fe246c.js +2 -0
- package/test-site/dist/362.536eff787d2380fe246c.js.map +1 -0
- package/test-site/dist/653.486966b108d224551296.js +2 -0
- package/test-site/dist/653.486966b108d224551296.js.map +1 -0
- package/test-site/dist/74e025d3fe9a7b7f8503054e2563b353.jpg +0 -0
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js +3 -0
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js.LICENSE.txt +106 -0
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js.map +1 -0
- package/test-site/dist/95ec738c0b7faac5b5c9126794446bbd.svg +4 -0
- package/test-site/dist/app.612058b36c74787759ac.css +61 -0
- package/test-site/dist/app.612058b36c74787759ac.css.map +1 -0
- package/test-site/dist/app.612058b36c74787759ac.js +2 -0
- package/test-site/dist/app.612058b36c74787759ac.js.map +1 -0
- package/test-site/dist/cb28cdb1468c915e27e5cec9af64f22f.svg +1 -0
- package/test-site/dist/index.html +1 -0
- package/test-site/dist/report.html +39 -0
- package/test-site/dist/runtime.c7aeaf7b967496cb076f.js +2 -0
- package/test-site/dist/runtime.c7aeaf7b967496cb076f.js.map +1 -0
- package/test-site/eslint.config.js +12 -0
- package/test-site/package-lock.json +19226 -0
- package/test-site/package.json +29 -0
- package/test-site/public/index.html +10 -0
- package/test-site/site.config.build.tsx +27 -0
- package/test-site/site.config.dev.tsx +27 -0
- package/test-site/src/authenticated-page/AuthenticatedPage.tsx +18 -0
- package/test-site/src/authenticated-page/i18n/index.ts +27 -0
- package/test-site/src/authenticated-page/index.tsx +28 -0
- package/test-site/src/example-page/ExamplePage.tsx +79 -0
- package/test-site/src/example-page/Image.tsx +11 -0
- package/test-site/src/example-page/ParagonPreview.jsx +66 -0
- package/test-site/src/example-page/apple.jpg +0 -0
- package/test-site/src/example-page/apple.svg +1 -0
- package/test-site/src/example-page/index.ts +16 -0
- package/test-site/src/i18n/README.md +3 -0
- package/test-site/src/i18n/messages/frontend-app-sample/ar.json +4 -0
- package/test-site/src/i18n/messages/frontend-app-sample/eo.json +1 -0
- package/test-site/src/i18n/messages/frontend-app-sample/es_419.json +4 -0
- package/test-site/src/i18n/messages/frontend-component-emptylangs/ar.json +1 -0
- package/test-site/src/i18n/messages/frontend-component-singlelang/ar.json +3 -0
- package/test-site/src/iframe-widget/IframeWidget.tsx +14 -0
- package/test-site/src/iframe-widget/index.ts +16 -0
- package/test-site/src/index.tsx +3 -0
- package/test-site/src/messages.js +11 -0
- package/test-site/src/site.scss +11 -0
- package/test-site/tsconfig.json +14 -0
- package/tools/babel/babel.config.js +27 -0
- package/tools/babel.config.js +3 -0
- package/tools/cli/README.md +29 -0
- package/tools/cli/commands/pack.ts +9 -0
- package/tools/cli/commands/release.ts +27 -0
- package/tools/cli/commands/serve.ts +43 -0
- package/tools/cli/intl-imports.ts +274 -0
- package/tools/cli/openedx.ts +101 -0
- package/tools/cli/transifex-utils.ts +75 -0
- package/tools/cli/utils/ensureConfigFilenameOption.ts +40 -0
- package/tools/cli/utils/formatter.ts +10 -0
- package/tools/cli/utils/getResolvedConfigPath.ts +23 -0
- package/tools/cli/utils/prettyPrintTitle.ts +15 -0
- package/tools/cli/utils/printUsage.ts +53 -0
- package/tools/config-helpers/createConfig.ts +8 -0
- package/tools/config-helpers/createLintConfig.ts +14 -0
- package/tools/config-helpers/getBaseConfig.ts +11 -0
- package/tools/defaultConfigPaths.ts +30 -0
- package/tools/dist/babel/babel.config.js +28 -0
- package/tools/dist/cli/commands/pack.js +14 -0
- package/tools/dist/cli/commands/release.js +28 -0
- package/tools/dist/cli/commands/serve.js +44 -0
- package/tools/dist/cli/intl-imports.js +233 -0
- package/tools/dist/cli/openedx.js +100 -0
- package/tools/dist/cli/transifex-utils.js +68 -0
- package/tools/dist/cli/utils/ensureConfigFilenameOption.js +42 -0
- package/tools/dist/cli/utils/formatter.js +10 -0
- package/tools/dist/cli/utils/getResolvedConfigPath.js +28 -0
- package/tools/dist/cli/utils/prettyPrintTitle.js +17 -0
- package/tools/dist/cli/utils/printUsage.js +48 -0
- package/tools/dist/config-helpers/createConfig.js +13 -0
- package/tools/dist/config-helpers/createLintConfig.js +16 -0
- package/tools/dist/config-helpers/getBaseConfig.js +12 -0
- package/tools/dist/defaultConfigPaths.js +35 -0
- package/tools/dist/eslint/base.eslint.config.js +113 -0
- package/tools/dist/eslint.config.js +11 -0
- package/tools/dist/index.js +12 -0
- package/tools/dist/jest/jest.config.js +30 -0
- package/tools/dist/jest.config.js +20 -0
- package/tools/dist/types.js +25 -0
- package/tools/dist/typescript/tsconfig.json +32 -0
- package/tools/dist/webpack/common-config/all/getCodeRules.js +52 -0
- package/tools/dist/webpack/common-config/all/getFileLoaderRules.js +26 -0
- package/tools/dist/webpack/common-config/all/getIgnoreWarnings.js +14 -0
- package/tools/dist/webpack/common-config/all/getImageMinimizer.js +25 -0
- package/tools/dist/webpack/common-config/all/getStylesheetRule.js +112 -0
- package/tools/dist/webpack/common-config/dev/getDevServer.js +38 -0
- package/tools/dist/webpack/common-config/index.js +18 -0
- package/tools/dist/webpack/common-config/site/getHtmlWebpackPlugin.js +16 -0
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +91 -0
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/index.js +7 -0
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +3 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.js +108 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/index.js +7 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/assetUtils.js +64 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/htmlUtils.js +53 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/index.js +9 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/paragonStylesheetUtils.js +114 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/scriptUtils.js +146 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/stylesheetUtils.js +126 -0
- package/tools/dist/webpack/plugins/paragon-webpack-plugin/utils/tagUtils.js +57 -0
- package/tools/dist/webpack/types.js +2 -0
- package/tools/dist/webpack/utils/getLocalAliases.js +65 -0
- package/tools/dist/webpack/utils/getPublicPath.js +6 -0
- package/tools/dist/webpack/utils/getResolvedSiteConfigPath.js +32 -0
- package/tools/dist/webpack/utils/paragonUtils.js +138 -0
- package/tools/dist/webpack/webpack.config.build.js +80 -0
- package/tools/dist/webpack/webpack.config.dev.js +76 -0
- package/tools/dist/webpack/webpack.config.dev.shell.js +110 -0
- package/tools/eslint/base.eslint.config.js +124 -0
- package/tools/eslint/modules.d.ts +5 -0
- package/tools/eslint.config.js +15 -0
- package/tools/index.ts +3 -0
- package/tools/jest/jest.config.js +30 -0
- package/tools/jest.config.js +19 -0
- package/tools/tsconfig.json +24 -0
- package/tools/types.ts +21 -0
- package/tools/typescript/tsconfig.json +32 -0
- package/tools/webpack/common-config/README.md +15 -0
- package/tools/webpack/common-config/all/getCodeRules.ts +51 -0
- package/tools/webpack/common-config/all/getFileLoaderRules.ts +23 -0
- package/tools/webpack/common-config/all/getIgnoreWarnings.ts +13 -0
- package/tools/webpack/common-config/all/getImageMinimizer.ts +26 -0
- package/tools/webpack/common-config/all/getStylesheetRule.ts +111 -0
- package/tools/webpack/common-config/dev/getDevServer.ts +35 -0
- package/tools/webpack/common-config/index.ts +6 -0
- package/tools/webpack/common-config/site/getHtmlWebpackPlugin.ts +11 -0
- package/tools/webpack/modules.d.ts +6 -0
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.ts +102 -0
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/LICENSE +21 -0
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/README.md +7 -0
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/index.js +3 -0
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +1 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.ts +134 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/index.ts +3 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/assetUtils.ts +71 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/htmlUtils.ts +72 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/index.ts +6 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/paragonStylesheetUtils.ts +131 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/scriptUtils.ts +144 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/stylesheetUtils.ts +106 -0
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/tagUtils.ts +54 -0
- package/tools/webpack/types.ts +69 -0
- package/tools/webpack/utils/getLocalAliases.ts +65 -0
- package/tools/webpack/utils/getPublicPath.ts +3 -0
- package/tools/webpack/utils/getResolvedSiteConfigPath.ts +28 -0
- package/tools/webpack/utils/paragonUtils.ts +152 -0
- package/tools/webpack/webpack.config.build.ts +93 -0
- package/tools/webpack/webpack.config.dev.shell.ts +122 -0
- package/tools/webpack/webpack.config.dev.ts +90 -0
- package/tsconfig.json +23 -0
- package/types.ts +99 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createConfig;
|
|
7
|
+
const webpack_merge_1 = require("webpack-merge");
|
|
8
|
+
const getBaseConfig_1 = __importDefault(require("./getBaseConfig"));
|
|
9
|
+
function createConfig(configType, configFragment = {}) {
|
|
10
|
+
const baseConfig = (0, getBaseConfig_1.default)(configType);
|
|
11
|
+
return (0, webpack_merge_1.merge)(baseConfig, configFragment);
|
|
12
|
+
}
|
|
13
|
+
;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createLintConfig;
|
|
7
|
+
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
8
|
+
const types_1 = require("../types");
|
|
9
|
+
const getBaseConfig_1 = __importDefault(require("./getBaseConfig"));
|
|
10
|
+
function createLintConfig(...configs) {
|
|
11
|
+
const baseConfig = (0, getBaseConfig_1.default)(types_1.ConfigTypes.LINT);
|
|
12
|
+
return typescript_eslint_1.default.config({
|
|
13
|
+
extends: baseConfig,
|
|
14
|
+
}, ...configs);
|
|
15
|
+
}
|
|
16
|
+
;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getBaseConfig;
|
|
4
|
+
const defaultConfigPaths_1 = require("../defaultConfigPaths");
|
|
5
|
+
function getBaseConfig(configType) {
|
|
6
|
+
const configPaths = defaultConfigPaths_1.defaultConfigPaths[configType];
|
|
7
|
+
if (configPaths === undefined) {
|
|
8
|
+
throw new Error(`openedx: ${configType} is not a supported config type.`);
|
|
9
|
+
}
|
|
10
|
+
return require(require.resolve(configPaths[configPaths.length - 1]));
|
|
11
|
+
}
|
|
12
|
+
;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.defaultConfigPaths = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
// These config paths are tested in the order they're defined, so the last ones are the last fallback.
|
|
10
|
+
exports.defaultConfigPaths = {
|
|
11
|
+
[types_1.ConfigTypes.BABEL]: [
|
|
12
|
+
path_1.default.resolve(process.cwd(), 'babel.config.js'),
|
|
13
|
+
path_1.default.resolve(__dirname, './babel/babel.config.js'),
|
|
14
|
+
],
|
|
15
|
+
[types_1.ConfigTypes.WEBPACK_BUILD]: [
|
|
16
|
+
path_1.default.resolve(process.cwd(), 'webpack.config.build.js'),
|
|
17
|
+
path_1.default.resolve(__dirname, './webpack/webpack.config.build.js'),
|
|
18
|
+
],
|
|
19
|
+
[types_1.ConfigTypes.WEBPACK_DEV]: [
|
|
20
|
+
path_1.default.resolve(process.cwd(), 'webpack.config.dev.js'),
|
|
21
|
+
path_1.default.resolve(__dirname, './webpack/webpack.config.dev.js'),
|
|
22
|
+
],
|
|
23
|
+
[types_1.ConfigTypes.WEBPACK_DEV_SHELL]: [
|
|
24
|
+
path_1.default.resolve(process.cwd(), 'webpack.config.dev.shell.js'),
|
|
25
|
+
path_1.default.resolve(__dirname, './webpack/webpack.config.dev.shell.js'),
|
|
26
|
+
],
|
|
27
|
+
[types_1.ConfigTypes.LINT]: [
|
|
28
|
+
path_1.default.resolve(process.cwd(), 'eslint.config.js'),
|
|
29
|
+
path_1.default.resolve(__dirname, './eslint/base.eslint.config.js'),
|
|
30
|
+
],
|
|
31
|
+
[types_1.ConfigTypes.TEST]: [
|
|
32
|
+
path_1.default.resolve(process.cwd(), 'jest.config.js'),
|
|
33
|
+
path_1.default.resolve(__dirname, './jest/jest.config.js'),
|
|
34
|
+
],
|
|
35
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
const { fixupPluginRules } = require('@eslint/compat');
|
|
4
|
+
const eslint = require('@eslint/js');
|
|
5
|
+
const formatjs = require('eslint-plugin-formatjs');
|
|
6
|
+
const jest = require('eslint-plugin-jest');
|
|
7
|
+
const jsxA11y = require('eslint-plugin-jsx-a11y');
|
|
8
|
+
const react = require('eslint-plugin-react');
|
|
9
|
+
const reactHooks = require('eslint-plugin-react-hooks');
|
|
10
|
+
const globals = require('globals');
|
|
11
|
+
const tseslint = require('typescript-eslint');
|
|
12
|
+
const stylistic = require('@stylistic/eslint-plugin');
|
|
13
|
+
module.exports = tseslint.config(eslint.configs.recommended, ...tseslint.configs.stylisticTypeChecked, ...tseslint.configs.recommended, stylistic.configs['recommended-flat'], {
|
|
14
|
+
ignores: [
|
|
15
|
+
'coverage/*',
|
|
16
|
+
'dist/*',
|
|
17
|
+
'node_modules/*',
|
|
18
|
+
'**/__mocks__/*',
|
|
19
|
+
'**/__snapshots__/*',
|
|
20
|
+
],
|
|
21
|
+
}, {
|
|
22
|
+
languageOptions: {
|
|
23
|
+
parserOptions: {
|
|
24
|
+
projectService: true,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
languageOptions: {
|
|
29
|
+
...(react.configs.flat !== undefined ? react.configs.flat.recommended.languageOptions : {}),
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.browser,
|
|
32
|
+
...globals.node,
|
|
33
|
+
...globals.jest,
|
|
34
|
+
PARAGON_THEME: 'readonly',
|
|
35
|
+
newrelic: 'readonly',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
plugins: {
|
|
39
|
+
jest,
|
|
40
|
+
// Type assertion is workaround for incorrect TypeScript
|
|
41
|
+
// types in eslint-plugin-react
|
|
42
|
+
//
|
|
43
|
+
// TODO: Remove when types are fixed in eslint-plugin-react
|
|
44
|
+
// - https://github.com/jsx-eslint/eslint-plugin-react/issues/3838
|
|
45
|
+
react: /** @type {import('eslint').ESLint.Plugin} */ (react),
|
|
46
|
+
'react-hooks': fixupPluginRules(reactHooks),
|
|
47
|
+
formatjs,
|
|
48
|
+
'jsx-a11y': jsxA11y,
|
|
49
|
+
},
|
|
50
|
+
settings: {
|
|
51
|
+
react: {
|
|
52
|
+
version: 'detect',
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
rules: {
|
|
57
|
+
// For some reasons the 'flat' key in react.configs is optional, so Typescript complains if
|
|
58
|
+
// we don't guard using it. But... it exists in the export, so something's odd with their types.
|
|
59
|
+
...(react.configs.flat !== undefined ? react.configs.flat.recommended.rules : {}),
|
|
60
|
+
...(react.configs.flat !== undefined ? react.configs.flat['jsx-runtime'].rules : {}),
|
|
61
|
+
...reactHooks.configs.recommended.rules,
|
|
62
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
63
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
|
64
|
+
'react/no-array-index-key': 'error',
|
|
65
|
+
'formatjs/enforce-description': ['error', 'literal'],
|
|
66
|
+
'jsx-a11y/label-has-associated-control': ['error', {
|
|
67
|
+
labelComponents: [],
|
|
68
|
+
labelAttributes: [],
|
|
69
|
+
controlComponents: [],
|
|
70
|
+
assert: 'htmlFor',
|
|
71
|
+
depth: 25,
|
|
72
|
+
}],
|
|
73
|
+
// https://github.com/evcohen/eslint-plugin-jsx-a11y/issues/340#issuecomment-338424908
|
|
74
|
+
'jsx-a11y/anchor-is-valid': ['error', {
|
|
75
|
+
components: ['Link'],
|
|
76
|
+
specialLink: ['to'],
|
|
77
|
+
}],
|
|
78
|
+
'@typescript-eslint/no-unused-vars': ['error', {
|
|
79
|
+
caughtErrors: 'none',
|
|
80
|
+
}],
|
|
81
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
82
|
+
'@stylistic/semi': ['error', 'always', { omitLastInOneLineBlock: true, omitLastInOneLineClassBody: true }],
|
|
83
|
+
'@stylistic/quotes': ['error', 'single', {
|
|
84
|
+
avoidEscape: true,
|
|
85
|
+
allowTemplateLiterals: true,
|
|
86
|
+
}],
|
|
87
|
+
'@stylistic/comma-dangle': 'off',
|
|
88
|
+
'@stylistic/quote-props': ['error', 'as-needed'],
|
|
89
|
+
'@stylistic/arrow-parens': 'off',
|
|
90
|
+
'@stylistic/jsx-one-expression-per-line': 'off',
|
|
91
|
+
'@stylistic/multiline-ternary': 'off',
|
|
92
|
+
'@stylistic/brace-style': ['error', '1tbs'],
|
|
93
|
+
'@stylistic/member-delimiter-style': ['error', {
|
|
94
|
+
multiline: {
|
|
95
|
+
delimiter: 'comma',
|
|
96
|
+
requireLast: true,
|
|
97
|
+
},
|
|
98
|
+
singleline: {
|
|
99
|
+
delimiter: 'comma',
|
|
100
|
+
requireLast: false,
|
|
101
|
+
}
|
|
102
|
+
}],
|
|
103
|
+
},
|
|
104
|
+
}, {
|
|
105
|
+
files: [
|
|
106
|
+
'babel.config.js',
|
|
107
|
+
'jest.config.js',
|
|
108
|
+
'eslint.config.js'
|
|
109
|
+
],
|
|
110
|
+
rules: {
|
|
111
|
+
'@typescript-eslint/no-require-imports': 'off'
|
|
112
|
+
}
|
|
113
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
const tseslint = require('typescript-eslint');
|
|
4
|
+
const eslintConfig = require('./eslint/base.eslint.config.js');
|
|
5
|
+
module.exports = tseslint.config({
|
|
6
|
+
extends: eslintConfig,
|
|
7
|
+
}, {
|
|
8
|
+
rules: {
|
|
9
|
+
'@typescript-eslint/no-require-imports': 'off'
|
|
10
|
+
}
|
|
11
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getBaseConfig = exports.createLintConfig = exports.createConfig = void 0;
|
|
7
|
+
var createConfig_1 = require("./config-helpers/createConfig");
|
|
8
|
+
Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return __importDefault(createConfig_1).default; } });
|
|
9
|
+
var createLintConfig_1 = require("./config-helpers/createLintConfig");
|
|
10
|
+
Object.defineProperty(exports, "createLintConfig", { enumerable: true, get: function () { return __importDefault(createLintConfig_1).default; } });
|
|
11
|
+
var getBaseConfig_1 = require("./config-helpers/getBaseConfig");
|
|
12
|
+
Object.defineProperty(exports, "getBaseConfig", { enumerable: true, get: function () { return __importDefault(getBaseConfig_1).default; } });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require('path');
|
|
3
|
+
module.exports = {
|
|
4
|
+
testEnvironment: 'jsdom',
|
|
5
|
+
testEnvironmentOptions: {
|
|
6
|
+
url: 'http://localhost/',
|
|
7
|
+
},
|
|
8
|
+
rootDir: process.cwd(),
|
|
9
|
+
moduleNameMapper: {
|
|
10
|
+
'\\.(css|scss)$': require.resolve('identity-obj-proxy'),
|
|
11
|
+
'site.config': path.resolve(process.cwd(), './site.config.test.tsx'),
|
|
12
|
+
},
|
|
13
|
+
collectCoverageFrom: [
|
|
14
|
+
'src/**/*.{js,jsx,ts,tsx}',
|
|
15
|
+
],
|
|
16
|
+
coveragePathIgnorePatterns: [
|
|
17
|
+
'/node_modules/',
|
|
18
|
+
],
|
|
19
|
+
transformIgnorePatterns: [
|
|
20
|
+
'/node_modules/(?!(@openedx|@edx)/)',
|
|
21
|
+
],
|
|
22
|
+
modulePathIgnorePatterns: [
|
|
23
|
+
'/dist/',
|
|
24
|
+
],
|
|
25
|
+
testPathIgnorePatterns: [
|
|
26
|
+
'/site.config.test.tsx',
|
|
27
|
+
'/node_modules/',
|
|
28
|
+
'/dist/',
|
|
29
|
+
],
|
|
30
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
module.exports = {
|
|
3
|
+
testEnvironment: 'node',
|
|
4
|
+
testEnvironmentOptions: {
|
|
5
|
+
url: 'http://localhost/',
|
|
6
|
+
},
|
|
7
|
+
collectCoverageFrom: [
|
|
8
|
+
'cli/**/*.{js,jsx,ts,tsx}',
|
|
9
|
+
],
|
|
10
|
+
transformIgnorePatterns: [
|
|
11
|
+
'/node_modules/(?!(@openedx|@edx)/)',
|
|
12
|
+
],
|
|
13
|
+
modulePathIgnorePatterns: [
|
|
14
|
+
'/dist/',
|
|
15
|
+
],
|
|
16
|
+
testPathIgnorePatterns: [
|
|
17
|
+
'/node_modules/',
|
|
18
|
+
'/dist/',
|
|
19
|
+
],
|
|
20
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandTypes = exports.ConfigTypes = void 0;
|
|
4
|
+
var ConfigTypes;
|
|
5
|
+
(function (ConfigTypes) {
|
|
6
|
+
ConfigTypes["BABEL"] = "babel";
|
|
7
|
+
ConfigTypes["WEBPACK_BUILD"] = "webpack-build";
|
|
8
|
+
ConfigTypes["WEBPACK_DEV"] = "webpack-dev";
|
|
9
|
+
ConfigTypes["WEBPACK_DEV_SHELL"] = "webpack-dev-shell";
|
|
10
|
+
ConfigTypes["LINT"] = "lint";
|
|
11
|
+
ConfigTypes["TEST"] = "test";
|
|
12
|
+
})(ConfigTypes || (exports.ConfigTypes = ConfigTypes = {}));
|
|
13
|
+
var CommandTypes;
|
|
14
|
+
(function (CommandTypes) {
|
|
15
|
+
CommandTypes["RELEASE"] = "release";
|
|
16
|
+
CommandTypes["PACK"] = "pack";
|
|
17
|
+
CommandTypes["LINT"] = "lint";
|
|
18
|
+
CommandTypes["TEST"] = "test";
|
|
19
|
+
CommandTypes["BUILD"] = "build";
|
|
20
|
+
CommandTypes["DEV_SHELL"] = "dev:shell";
|
|
21
|
+
CommandTypes["DEV"] = "dev";
|
|
22
|
+
CommandTypes["FORMAT_JS"] = "formatjs";
|
|
23
|
+
CommandTypes["SERVE"] = "serve";
|
|
24
|
+
CommandTypes["HELP"] = "help";
|
|
25
|
+
})(CommandTypes || (exports.CommandTypes = CommandTypes = {}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"allowJs": true,
|
|
4
|
+
"allowSyntheticDefaultImports": true,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"forceConsistentCasingInFileNames": true,
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"lib": [
|
|
10
|
+
"DOM",
|
|
11
|
+
"DOM.Iterable",
|
|
12
|
+
"ESNext",
|
|
13
|
+
"esnext.intl",
|
|
14
|
+
"es2017.intl",
|
|
15
|
+
"es2018.intl"
|
|
16
|
+
],
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"module": "ESNext",
|
|
19
|
+
"moduleResolution": "node",
|
|
20
|
+
"noEmit": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"noImplicitAny": false,
|
|
23
|
+
"noImplicitThis": true,
|
|
24
|
+
"noUnusedParameters": true,
|
|
25
|
+
"resolveJsonModule": true,
|
|
26
|
+
"skipLibCheck": true,
|
|
27
|
+
"sourceMap": true,
|
|
28
|
+
"strict": true,
|
|
29
|
+
"strictFunctionTypes": false,
|
|
30
|
+
"target": "ES6"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getCodeRules;
|
|
7
|
+
const ts_transformer_1 = require("@formatjs/ts-transformer");
|
|
8
|
+
const react_refresh_typescript_1 = __importDefault(require("react-refresh-typescript"));
|
|
9
|
+
function getCodeRules(mode, resolvedSiteConfigPath) {
|
|
10
|
+
const rules = [
|
|
11
|
+
{
|
|
12
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
13
|
+
include: [
|
|
14
|
+
/src/,
|
|
15
|
+
/node_modules\/@openedx\/frontend-base/,
|
|
16
|
+
resolvedSiteConfigPath,
|
|
17
|
+
],
|
|
18
|
+
use: {
|
|
19
|
+
loader: require.resolve('ts-loader'),
|
|
20
|
+
options: {
|
|
21
|
+
transpileOnly: true,
|
|
22
|
+
compilerOptions: {
|
|
23
|
+
noEmit: false,
|
|
24
|
+
},
|
|
25
|
+
getCustomTransformers() {
|
|
26
|
+
const before = [
|
|
27
|
+
(0, ts_transformer_1.transform)({
|
|
28
|
+
overrideIdFn: '[sha512:contenthash:base64:6]',
|
|
29
|
+
}),
|
|
30
|
+
];
|
|
31
|
+
if (mode === 'dev') {
|
|
32
|
+
before.push((0, react_refresh_typescript_1.default)());
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
before,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
if (mode === 'production') {
|
|
43
|
+
rules.push({
|
|
44
|
+
test: /\.(js|jsx|ts|tsx)$/,
|
|
45
|
+
use: [
|
|
46
|
+
require.resolve('source-map-loader'),
|
|
47
|
+
],
|
|
48
|
+
enforce: 'pre',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return rules;
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getFileLoaderRules;
|
|
4
|
+
function getFileLoaderRules() {
|
|
5
|
+
return [
|
|
6
|
+
// Webpack, by default, uses the url-loader for images and fonts that are required/included by
|
|
7
|
+
// files it processes, which just base64 encodes them and inlines them in the javascript
|
|
8
|
+
// bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
|
|
9
|
+
// file-loader instead to copy the files directly to the output directory.
|
|
10
|
+
{
|
|
11
|
+
test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
|
|
12
|
+
loader: require.resolve('file-loader'),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
test: /favicon.ico$/,
|
|
16
|
+
loader: require.resolve('file-loader'),
|
|
17
|
+
options: {
|
|
18
|
+
name: '[name].[ext]', // <-- retain original file name
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
|
|
23
|
+
loader: require.resolve('file-loader'),
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = getIgnoreWarnings;
|
|
4
|
+
function getIgnoreWarnings() {
|
|
5
|
+
return [
|
|
6
|
+
// Ignore warnings raised by source-map-loader.
|
|
7
|
+
// some third party packages may ship miss-configured sourcemaps, that interrupts the build
|
|
8
|
+
// See: https://github.com/facebook/create-react-app/discussions/11278#discussioncomment-1780169
|
|
9
|
+
(warning) => !!(
|
|
10
|
+
// @ts-expect-error 'resource' is something TypeScript can't find for whatever reason.
|
|
11
|
+
warning.module?.resource.includes('node_modules')
|
|
12
|
+
&& warning.details?.includes('source-map-loader')),
|
|
13
|
+
];
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getImageMinimizer;
|
|
7
|
+
const image_minimizer_webpack_plugin_1 = __importDefault(require("image-minimizer-webpack-plugin"));
|
|
8
|
+
function getImageMinimizer() {
|
|
9
|
+
return [
|
|
10
|
+
'...',
|
|
11
|
+
new image_minimizer_webpack_plugin_1.default({
|
|
12
|
+
minimizer: {
|
|
13
|
+
implementation: image_minimizer_webpack_plugin_1.default.sharpMinify,
|
|
14
|
+
options: {
|
|
15
|
+
encodeOptions: {
|
|
16
|
+
...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => ({ ...accumulator, [value]: { progressive: true, quality: 65 } }), {}),
|
|
17
|
+
gif: {
|
|
18
|
+
effort: 5,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getStylesheetRule;
|
|
7
|
+
const autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
8
|
+
const cssnano_1 = __importDefault(require("cssnano"));
|
|
9
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const postcss_custom_media_1 = __importDefault(require("postcss-custom-media"));
|
|
12
|
+
const postcss_rtlcss_1 = __importDefault(require("postcss-rtlcss"));
|
|
13
|
+
/**
|
|
14
|
+
* There are a few things we need to do here.
|
|
15
|
+
*
|
|
16
|
+
* - We only want to use MiniCssExtractPlugin on dependencies in dev, but not on our source code.
|
|
17
|
+
* - We only want CssNano in production.
|
|
18
|
+
*/
|
|
19
|
+
function getStylesheetRule(mode) {
|
|
20
|
+
if (mode === 'production') {
|
|
21
|
+
// In the production case, all files should go through MiniCssExtractPlugin.
|
|
22
|
+
return {
|
|
23
|
+
test: /(.scss|.css)$/,
|
|
24
|
+
use: [
|
|
25
|
+
mini_css_extract_plugin_1.default.loader,
|
|
26
|
+
...getStyleUseConfig(mode),
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// In the dev case, only our @openedx dependencies go through MiniCssExtractPlugin.
|
|
32
|
+
// We are not extracting CSS from the javascript bundles in development because extracting
|
|
33
|
+
// prevents hot-reloading from working, it increases build time, and we don't care about
|
|
34
|
+
// flash-of-unstyled-content issues in development.
|
|
35
|
+
return {
|
|
36
|
+
test: /(.scss|.css)$/,
|
|
37
|
+
oneOf: [
|
|
38
|
+
{
|
|
39
|
+
resource: /(@openedx\/paragon|@(open)?edx\/brand)/,
|
|
40
|
+
use: [
|
|
41
|
+
mini_css_extract_plugin_1.default.loader,
|
|
42
|
+
...getStyleUseConfig(mode),
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
use: [
|
|
47
|
+
require.resolve('style-loader'), // creates style nodes from JS strings
|
|
48
|
+
...getStyleUseConfig(mode),
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function getStyleUseConfig(mode) {
|
|
56
|
+
return [
|
|
57
|
+
{
|
|
58
|
+
loader: require.resolve('css-loader'), // translates CSS into CommonJS
|
|
59
|
+
options: {
|
|
60
|
+
sourceMap: true,
|
|
61
|
+
modules: {
|
|
62
|
+
// namedExport defaults to true in css-loader v7, but we rely on the old behavior.
|
|
63
|
+
// Details here:
|
|
64
|
+
// https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#700-2024-04-04
|
|
65
|
+
namedExport: false,
|
|
66
|
+
mode: 'icss',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
loader: require.resolve('postcss-loader'),
|
|
72
|
+
options: {
|
|
73
|
+
postcssOptions: {
|
|
74
|
+
plugins: getPostCssLoaderPlugins(mode), // Different behavior for dev and production.
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
require.resolve('resolve-url-loader'),
|
|
79
|
+
{
|
|
80
|
+
loader: require.resolve('sass-loader'), // compiles Sass to CSS
|
|
81
|
+
options: {
|
|
82
|
+
sourceMap: true,
|
|
83
|
+
sassOptions: {
|
|
84
|
+
includePaths: [
|
|
85
|
+
path_1.default.join(process.cwd(), 'node_modules'),
|
|
86
|
+
path_1.default.join(process.cwd(), 'src'),
|
|
87
|
+
],
|
|
88
|
+
// Silences compiler deprecation warnings. They mostly come from bootstrap and/or paragon.
|
|
89
|
+
quietDeps: true,
|
|
90
|
+
silenceDeprecations: ['abs-percent', 'color-functions', 'import', 'mixed-decls', 'global-builtin', 'legacy-js-api'],
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* This exists just to conditionally include CssNano in production.
|
|
98
|
+
*/
|
|
99
|
+
function getPostCssLoaderPlugins(mode) {
|
|
100
|
+
const plugins = [
|
|
101
|
+
(0, autoprefixer_1.default)({
|
|
102
|
+
remove: false, // Prevents removing vendor prefixes
|
|
103
|
+
}),
|
|
104
|
+
(0, postcss_rtlcss_1.default)(),
|
|
105
|
+
];
|
|
106
|
+
// We want CSSNano third, and only in production.
|
|
107
|
+
if (mode === 'production') {
|
|
108
|
+
plugins.push((0, cssnano_1.default)());
|
|
109
|
+
}
|
|
110
|
+
plugins.push((0, postcss_custom_media_1.default)());
|
|
111
|
+
return plugins;
|
|
112
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getDevServer;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const getPublicPath_1 = __importDefault(require("../../utils/getPublicPath"));
|
|
9
|
+
function getDevServer() {
|
|
10
|
+
return {
|
|
11
|
+
allowedHosts: 'all',
|
|
12
|
+
headers: {
|
|
13
|
+
'Access-Control-Allow-Origin': '*',
|
|
14
|
+
},
|
|
15
|
+
// For obvious reasons, 'auto' won't work for publicPath here, so we
|
|
16
|
+
// force '/' unless PUBLIC_PATH is set.
|
|
17
|
+
historyApiFallback: {
|
|
18
|
+
index: path_1.default.join((0, getPublicPath_1.default)('/'), 'index.html'),
|
|
19
|
+
disableDotRule: true,
|
|
20
|
+
},
|
|
21
|
+
host: 'apps.local.openedx.io',
|
|
22
|
+
hot: true,
|
|
23
|
+
port: process.env.PORT ?? 8080,
|
|
24
|
+
proxy: [
|
|
25
|
+
{
|
|
26
|
+
context: ['/api/mfe_config/v1'],
|
|
27
|
+
target: 'http://local.openedx.io:8000',
|
|
28
|
+
changeOrigin: true,
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
// Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
|
|
32
|
+
// for the WebpackDevServer client so it can learn when the files were
|
|
33
|
+
// updated. The WebpackDevServer client is included as an entry point
|
|
34
|
+
// in the webpack development configuration. Note that only changes
|
|
35
|
+
// to CSS are currently hot reloaded. JS changes will refresh the browser.
|
|
36
|
+
webSocketServer: 'ws',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getHtmlWebpackPlugin = exports.getDevServer = exports.getStylesheetRule = exports.getImageMinimizer = exports.getFileLoaderRules = exports.getCodeRules = void 0;
|
|
7
|
+
var getCodeRules_1 = require("./all/getCodeRules");
|
|
8
|
+
Object.defineProperty(exports, "getCodeRules", { enumerable: true, get: function () { return __importDefault(getCodeRules_1).default; } });
|
|
9
|
+
var getFileLoaderRules_1 = require("./all/getFileLoaderRules");
|
|
10
|
+
Object.defineProperty(exports, "getFileLoaderRules", { enumerable: true, get: function () { return __importDefault(getFileLoaderRules_1).default; } });
|
|
11
|
+
var getImageMinimizer_1 = require("./all/getImageMinimizer");
|
|
12
|
+
Object.defineProperty(exports, "getImageMinimizer", { enumerable: true, get: function () { return __importDefault(getImageMinimizer_1).default; } });
|
|
13
|
+
var getStylesheetRule_1 = require("./all/getStylesheetRule");
|
|
14
|
+
Object.defineProperty(exports, "getStylesheetRule", { enumerable: true, get: function () { return __importDefault(getStylesheetRule_1).default; } });
|
|
15
|
+
var getDevServer_1 = require("./dev/getDevServer");
|
|
16
|
+
Object.defineProperty(exports, "getDevServer", { enumerable: true, get: function () { return __importDefault(getDevServer_1).default; } });
|
|
17
|
+
var getHtmlWebpackPlugin_1 = require("./site/getHtmlWebpackPlugin");
|
|
18
|
+
Object.defineProperty(exports, "getHtmlWebpackPlugin", { enumerable: true, get: function () { return __importDefault(getHtmlWebpackPlugin_1).default; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = getHtmlWebpackPlugin;
|
|
7
|
+
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
// Generates an HTML file in the output directory.
|
|
10
|
+
function getHtmlWebpackPlugin() {
|
|
11
|
+
return new html_webpack_plugin_1.default({
|
|
12
|
+
inject: true, // Appends script tags linking to the webpack bundles at the end of the body
|
|
13
|
+
template: path_1.default.resolve(process.cwd(), 'public/index.html'),
|
|
14
|
+
chunks: ['app'],
|
|
15
|
+
});
|
|
16
|
+
}
|