@openedx/frontend-build 13.0.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.
Files changed (231) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +10 -0
  3. package/.github/workflows/add-depr-ticket-to-depr-board.yml +19 -0
  4. package/.github/workflows/add-remove-label-on-comment.yml +20 -0
  5. package/.github/workflows/ci.yml +30 -0
  6. package/.github/workflows/commitlint.yml +10 -0
  7. package/.github/workflows/lockfileversion-check.yml +13 -0
  8. package/.github/workflows/release.yml +34 -0
  9. package/.github/workflows/self-assign-issue.yml +12 -0
  10. package/.github/workflows/sync-master-alpha.yml +35 -0
  11. package/.nvmrc +1 -0
  12. package/LICENSE +661 -0
  13. package/README.md +295 -0
  14. package/bin/fedx-scripts.js +88 -0
  15. package/config/.eslintrc.js +45 -0
  16. package/config/babel-preserve-modules.config.js +30 -0
  17. package/config/babel-typescript.config.js +5 -0
  18. package/config/babel.config.js +41 -0
  19. package/config/getLocalAliases.js +67 -0
  20. package/config/jest/fallback.env.config.js +12 -0
  21. package/config/jest/fileMock.js +1 -0
  22. package/config/jest/setupTest.js +10 -0
  23. package/config/jest/svgrMock.js +4 -0
  24. package/config/jest.config.js +43 -0
  25. package/config/webpack.common.config.js +40 -0
  26. package/config/webpack.dev-stage.config.js +191 -0
  27. package/config/webpack.dev.config.js +193 -0
  28. package/config/webpack.prod.config.js +219 -0
  29. package/coverage/clover.xml +6 -0
  30. package/coverage/coverage-final.json +1 -0
  31. package/coverage/lcov-report/base.css +224 -0
  32. package/coverage/lcov-report/block-navigation.js +87 -0
  33. package/coverage/lcov-report/favicon.png +0 -0
  34. package/coverage/lcov-report/index.html +101 -0
  35. package/coverage/lcov-report/prettify.css +1 -0
  36. package/coverage/lcov-report/prettify.js +2 -0
  37. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  38. package/coverage/lcov-report/sorter.js +196 -0
  39. package/coverage/lcov.info +0 -0
  40. package/docs/0001-non-usage-of-gatsby.rst +37 -0
  41. package/docs/0002-js-environment-config.md +47 -0
  42. package/docs/0003-fedx-scripts-serve.md +37 -0
  43. package/example/.env +0 -0
  44. package/example/.env.development +3 -0
  45. package/example/.env.test +2 -0
  46. package/example/.eslintignore +5 -0
  47. package/example/.eslintrc.js +3 -0
  48. package/example/dist/6.215b56a13e78398da5e3.js +3 -0
  49. package/example/dist/6.215b56a13e78398da5e3.js.LICENSE.txt +41 -0
  50. package/example/dist/6.215b56a13e78398da5e3.js.map +1 -0
  51. package/example/dist/app.80862a4da69beb9b3c51.css +3 -0
  52. package/example/dist/app.80862a4da69beb9b3c51.css.map +1 -0
  53. package/example/dist/app.80862a4da69beb9b3c51.js +2 -0
  54. package/example/dist/app.80862a4da69beb9b3c51.js.map +1 -0
  55. package/example/dist/b04e4301608fdcff39abf8f70b4a7de6.jpg +0 -0
  56. package/example/dist/babel/App.js +85 -0
  57. package/example/dist/babel/App.js.map +1 -0
  58. package/example/dist/babel/App.test.jsx +11 -0
  59. package/example/dist/babel/__snapshots__/App.test.jsx.snap +108 -0
  60. package/example/dist/babel/apple.jpg +0 -0
  61. package/example/dist/babel/apple.svg +1 -0
  62. package/example/dist/babel/index.js +13 -0
  63. package/example/dist/babel/index.js.map +1 -0
  64. package/example/dist/babel/style.scss +9 -0
  65. package/example/dist/cb28cdb1468c915e27e5cec9af64f22f.svg +1 -0
  66. package/example/dist/index.html +4 -0
  67. package/example/dist/report.html +39 -0
  68. package/example/dist/runtime.3eabd67eaf067d6c2f46.js +2 -0
  69. package/example/dist/runtime.3eabd67eaf067d6c2f46.js.map +1 -0
  70. package/example/env.config.js +6 -0
  71. package/example/node_modules/.package-lock.json +98 -0
  72. package/example/node_modules/js-tokens/CHANGELOG.md +151 -0
  73. package/example/node_modules/js-tokens/LICENSE +21 -0
  74. package/example/node_modules/js-tokens/README.md +240 -0
  75. package/example/node_modules/js-tokens/index.js +23 -0
  76. package/example/node_modules/js-tokens/package.json +30 -0
  77. package/example/node_modules/loose-envify/LICENSE +21 -0
  78. package/example/node_modules/loose-envify/README.md +45 -0
  79. package/example/node_modules/loose-envify/cli.js +16 -0
  80. package/example/node_modules/loose-envify/custom.js +4 -0
  81. package/example/node_modules/loose-envify/index.js +3 -0
  82. package/example/node_modules/loose-envify/loose-envify.js +36 -0
  83. package/example/node_modules/loose-envify/package.json +36 -0
  84. package/example/node_modules/loose-envify/replace.js +65 -0
  85. package/example/node_modules/object-assign/index.js +90 -0
  86. package/example/node_modules/object-assign/license +21 -0
  87. package/example/node_modules/object-assign/package.json +42 -0
  88. package/example/node_modules/object-assign/readme.md +61 -0
  89. package/example/node_modules/prop-types/LICENSE +21 -0
  90. package/example/node_modules/prop-types/README.md +302 -0
  91. package/example/node_modules/prop-types/checkPropTypes.js +103 -0
  92. package/example/node_modules/prop-types/factory.js +19 -0
  93. package/example/node_modules/prop-types/factoryWithThrowingShims.js +65 -0
  94. package/example/node_modules/prop-types/factoryWithTypeCheckers.js +610 -0
  95. package/example/node_modules/prop-types/index.js +19 -0
  96. package/example/node_modules/prop-types/lib/ReactPropTypesSecret.js +12 -0
  97. package/example/node_modules/prop-types/lib/has.js +1 -0
  98. package/example/node_modules/prop-types/package.json +60 -0
  99. package/example/node_modules/prop-types/prop-types.js +1315 -0
  100. package/example/node_modules/prop-types/prop-types.min.js +1 -0
  101. package/example/node_modules/react/LICENSE +21 -0
  102. package/example/node_modules/react/README.md +13 -0
  103. package/example/node_modules/react/build-info.json +8 -0
  104. package/example/node_modules/react/cjs/react-jsx-dev-runtime.development.js +889 -0
  105. package/example/node_modules/react/cjs/react-jsx-dev-runtime.production.min.js +9 -0
  106. package/example/node_modules/react/cjs/react-jsx-runtime.development.js +911 -0
  107. package/example/node_modules/react/cjs/react-jsx-runtime.production.min.js +10 -0
  108. package/example/node_modules/react/cjs/react.development.js +1912 -0
  109. package/example/node_modules/react/cjs/react.production.min.js +25 -0
  110. package/example/node_modules/react/index.js +7 -0
  111. package/example/node_modules/react/jsx-dev-runtime.js +7 -0
  112. package/example/node_modules/react/jsx-runtime.js +7 -0
  113. package/example/node_modules/react/package.json +44 -0
  114. package/example/node_modules/react/umd/react.development.js +3318 -0
  115. package/example/node_modules/react/umd/react.production.min.js +32 -0
  116. package/example/node_modules/react/umd/react.profiling.min.js +39 -0
  117. package/example/node_modules/react-dom/LICENSE +21 -0
  118. package/example/node_modules/react-dom/README.md +54 -0
  119. package/example/node_modules/react-dom/build-info.json +8 -0
  120. package/example/node_modules/react-dom/cjs/react-dom-server.browser.development.js +4043 -0
  121. package/example/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js +54 -0
  122. package/example/node_modules/react-dom/cjs/react-dom-server.node.development.js +4085 -0
  123. package/example/node_modules/react-dom/cjs/react-dom-server.node.production.min.js +55 -0
  124. package/example/node_modules/react-dom/cjs/react-dom-test-utils.development.js +1480 -0
  125. package/example/node_modules/react-dom/cjs/react-dom-test-utils.production.min.js +35 -0
  126. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.development.js +141 -0
  127. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.browser.production.min.js +11 -0
  128. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.node.development.js +162 -0
  129. package/example/node_modules/react-dom/cjs/react-dom-unstable-fizz.node.production.min.js +12 -0
  130. package/example/node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.development.js +1629 -0
  131. package/example/node_modules/react-dom/cjs/react-dom-unstable-native-dependencies.production.min.js +31 -0
  132. package/example/node_modules/react-dom/cjs/react-dom.development.js +25012 -0
  133. package/example/node_modules/react-dom/cjs/react-dom.production.min.js +292 -0
  134. package/example/node_modules/react-dom/cjs/react-dom.profiling.min.js +299 -0
  135. package/example/node_modules/react-dom/index.js +38 -0
  136. package/example/node_modules/react-dom/package.json +60 -0
  137. package/example/node_modules/react-dom/profiling.js +38 -0
  138. package/example/node_modules/react-dom/server.browser.js +7 -0
  139. package/example/node_modules/react-dom/server.js +3 -0
  140. package/example/node_modules/react-dom/server.node.js +7 -0
  141. package/example/node_modules/react-dom/test-utils.js +7 -0
  142. package/example/node_modules/react-dom/umd/react-dom-server.browser.development.js +4147 -0
  143. package/example/node_modules/react-dom/umd/react-dom-server.browser.production.min.js +45 -0
  144. package/example/node_modules/react-dom/umd/react-dom-test-utils.development.js +1499 -0
  145. package/example/node_modules/react-dom/umd/react-dom-test-utils.production.min.js +30 -0
  146. package/example/node_modules/react-dom/umd/react-dom-unstable-fizz.browser.development.js +141 -0
  147. package/example/node_modules/react-dom/umd/react-dom-unstable-fizz.browser.production.min.js +10 -0
  148. package/example/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.development.js +1628 -0
  149. package/example/node_modules/react-dom/umd/react-dom-unstable-native-dependencies.production.min.js +28 -0
  150. package/example/node_modules/react-dom/umd/react-dom.development.js +25147 -0
  151. package/example/node_modules/react-dom/umd/react-dom.production.min.js +239 -0
  152. package/example/node_modules/react-dom/umd/react-dom.profiling.min.js +247 -0
  153. package/example/node_modules/react-dom/unstable-fizz.browser.js +7 -0
  154. package/example/node_modules/react-dom/unstable-fizz.js +3 -0
  155. package/example/node_modules/react-dom/unstable-fizz.node.js +7 -0
  156. package/example/node_modules/react-dom/unstable-native-dependencies.js +7 -0
  157. package/example/node_modules/react-is/LICENSE +21 -0
  158. package/example/node_modules/react-is/README.md +104 -0
  159. package/example/node_modules/react-is/build-info.json +8 -0
  160. package/example/node_modules/react-is/cjs/react-is.development.js +181 -0
  161. package/example/node_modules/react-is/cjs/react-is.production.min.js +15 -0
  162. package/example/node_modules/react-is/index.js +7 -0
  163. package/example/node_modules/react-is/package.json +27 -0
  164. package/example/node_modules/react-is/umd/react-is.development.js +181 -0
  165. package/example/node_modules/react-is/umd/react-is.production.min.js +13 -0
  166. package/example/node_modules/react-test-renderer/LICENSE +21 -0
  167. package/example/node_modules/react-test-renderer/README.md +26 -0
  168. package/example/node_modules/react-test-renderer/build-info.json +8 -0
  169. package/example/node_modules/react-test-renderer/cjs/react-test-renderer-shallow.development.js +1019 -0
  170. package/example/node_modules/react-test-renderer/cjs/react-test-renderer-shallow.production.min.js +35 -0
  171. package/example/node_modules/react-test-renderer/cjs/react-test-renderer.development.js +15596 -0
  172. package/example/node_modules/react-test-renderer/cjs/react-test-renderer.production.min.js +181 -0
  173. package/example/node_modules/react-test-renderer/index.js +7 -0
  174. package/example/node_modules/react-test-renderer/package.json +41 -0
  175. package/example/node_modules/react-test-renderer/shallow.js +7 -0
  176. package/example/node_modules/react-test-renderer/umd/react-test-renderer-shallow.development.js +1176 -0
  177. package/example/node_modules/react-test-renderer/umd/react-test-renderer-shallow.production.min.js +31 -0
  178. package/example/node_modules/react-test-renderer/umd/react-test-renderer.development.js +15709 -0
  179. package/example/node_modules/react-test-renderer/umd/react-test-renderer.production.min.js +151 -0
  180. package/example/node_modules/scheduler/LICENSE +21 -0
  181. package/example/node_modules/scheduler/README.md +9 -0
  182. package/example/node_modules/scheduler/build-info.json +8 -0
  183. package/example/node_modules/scheduler/cjs/scheduler-tracing.development.js +349 -0
  184. package/example/node_modules/scheduler/cjs/scheduler-tracing.production.min.js +10 -0
  185. package/example/node_modules/scheduler/cjs/scheduler-tracing.profiling.min.js +17 -0
  186. package/example/node_modules/scheduler/cjs/scheduler-unstable_mock.development.js +857 -0
  187. package/example/node_modules/scheduler/cjs/scheduler-unstable_mock.production.min.js +20 -0
  188. package/example/node_modules/scheduler/cjs/scheduler.development.js +858 -0
  189. package/example/node_modules/scheduler/cjs/scheduler.production.min.js +21 -0
  190. package/example/node_modules/scheduler/index.js +7 -0
  191. package/example/node_modules/scheduler/package.json +39 -0
  192. package/example/node_modules/scheduler/tracing-profiling.js +7 -0
  193. package/example/node_modules/scheduler/tracing.js +7 -0
  194. package/example/node_modules/scheduler/umd/scheduler-tracing.development.js +80 -0
  195. package/example/node_modules/scheduler/umd/scheduler-tracing.production.min.js +80 -0
  196. package/example/node_modules/scheduler/umd/scheduler-tracing.profiling.min.js +80 -0
  197. package/example/node_modules/scheduler/umd/scheduler-unstable_mock.development.js +857 -0
  198. package/example/node_modules/scheduler/umd/scheduler-unstable_mock.production.min.js +17 -0
  199. package/example/node_modules/scheduler/umd/scheduler.development.js +152 -0
  200. package/example/node_modules/scheduler/umd/scheduler.production.min.js +146 -0
  201. package/example/node_modules/scheduler/umd/scheduler.profiling.min.js +146 -0
  202. package/example/node_modules/scheduler/unstable_mock.js +7 -0
  203. package/example/package-lock.json +110 -0
  204. package/example/package.json +24 -0
  205. package/example/public/index.html +13 -0
  206. package/example/src/App.jsx +40 -0
  207. package/example/src/App.test.jsx +11 -0
  208. package/example/src/__snapshots__/App.test.jsx.snap +108 -0
  209. package/example/src/apple.jpg +0 -0
  210. package/example/src/apple.svg +1 -0
  211. package/example/src/index.jsx +13 -0
  212. package/example/src/style.scss +9 -0
  213. package/index.js +7 -0
  214. package/lib/ConfigPreset.js +28 -0
  215. package/lib/createConfig.js +7 -0
  216. package/lib/formatter.js +10 -0
  217. package/lib/getBaseConfig.js +9 -0
  218. package/lib/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.js +86 -0
  219. package/lib/plugins/html-webpack-new-relic-plugin/LICENSE +21 -0
  220. package/lib/plugins/html-webpack-new-relic-plugin/README.md +7 -0
  221. package/lib/plugins/html-webpack-new-relic-plugin/index.js +3 -0
  222. package/lib/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +80 -0
  223. package/lib/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +1 -0
  224. package/lib/presets.js +75 -0
  225. package/lib/resolveFilepaths.js +14 -0
  226. package/lib/resolvePrivateEnvConfig.js +15 -0
  227. package/lib/scripts/serve.js +78 -0
  228. package/openedx.yaml +10 -0
  229. package/package.json +95 -0
  230. package/renovate.json +22 -0
  231. package/smoke-test.sh +11 -0
@@ -0,0 +1,40 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ entry: {
5
+ app: path.resolve(process.cwd(), './src/index'),
6
+ },
7
+ output: {
8
+ path: path.resolve(process.cwd(), './dist'),
9
+ publicPath: '/',
10
+ },
11
+ resolve: {
12
+ alias: {
13
+ 'env.config': path.resolve(process.cwd(), './env.config'),
14
+ },
15
+ fallback: {
16
+ // This causes the system to return an empty object if it can't find an env.config.js file in
17
+ // the application being built.
18
+ 'env.config': false,
19
+ },
20
+ extensions: ['.js', '.jsx'],
21
+ },
22
+ ignoreWarnings: [
23
+ // Ignore warnings raised by source-map-loader.
24
+ // some third party packages may ship miss-configured sourcemaps, that interrupts the build
25
+ // See: https://github.com/facebook/create-react-app/discussions/11278#discussioncomment-1780169
26
+ /**
27
+ *
28
+ * @param {import('webpack').WebpackError} warning
29
+ * @returns {boolean}
30
+ */
31
+ function ignoreSourcemapsloaderWarnings(warning) {
32
+ return (
33
+ warning.module
34
+ && warning.module.resource.includes('node_modules')
35
+ && warning.details
36
+ && warning.details.includes('source-map-loader')
37
+ );
38
+ },
39
+ ],
40
+ };
@@ -0,0 +1,191 @@
1
+ // This is the dev Webpack config. All settings here should prefer a fast build
2
+ // time at the expense of creating larger, unoptimized bundles.
3
+ const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
4
+
5
+ const { merge } = require('webpack-merge');
6
+ const Dotenv = require('dotenv-webpack');
7
+ const dotenv = require('dotenv');
8
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
9
+ const path = require('path');
10
+ const PostCssAutoprefixerPlugin = require('autoprefixer');
11
+ const PostCssRTLCSS = require('postcss-rtlcss');
12
+ const PostCssCustomMediaCSS = require('postcss-custom-media');
13
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
14
+
15
+ const commonConfig = require('./webpack.common.config');
16
+ const presets = require('../lib/presets');
17
+ const resolvePrivateEnvConfig = require('../lib/resolvePrivateEnvConfig');
18
+ const getLocalAliases = require('./getLocalAliases');
19
+
20
+ // Add process env vars. Currently used only for setting the
21
+ // server port and the publicPath
22
+ dotenv.config({
23
+ path: path.resolve(process.cwd(), '.env.development-stage'),
24
+ });
25
+
26
+ // Allow private/local overrides of env vars from .env.development for config settings
27
+ // that you'd like to persist locally during development, without the risk of checking
28
+ // in temporary modifications to .env.development.
29
+ resolvePrivateEnvConfig('.env.private');
30
+
31
+ const aliases = getLocalAliases();
32
+ const PUBLIC_PATH = process.env.PUBLIC_PATH || '/';
33
+
34
+ module.exports = merge(commonConfig, {
35
+ mode: 'development',
36
+ devtool: 'eval-source-map',
37
+ output: {
38
+ publicPath: PUBLIC_PATH,
39
+ },
40
+ resolve: {
41
+ alias: aliases,
42
+ },
43
+ module: {
44
+ // Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
45
+ rules: [
46
+ // The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
47
+ // Babel is configured with the .babelrc file at the root of the project.
48
+ {
49
+ test: /\.(js|jsx)$/,
50
+ exclude: /node_modules\/(?!@(open)?edx)/,
51
+ use: {
52
+ loader: 'babel-loader',
53
+ options: {
54
+ configFile: presets.babel.resolvedFilepath,
55
+ // Caches result of loader to the filesystem. Future builds will attempt to read
56
+ // from the cache to avoid needing to run the expensive recompilation process
57
+ // on each run.
58
+ cacheDirectory: true,
59
+ plugins: [
60
+ require.resolve('react-refresh/babel'),
61
+ ],
62
+ },
63
+ },
64
+ },
65
+ // We are not extracting CSS from the javascript bundles in development because extracting
66
+ // prevents hot-reloading from working, it increases build time, and we don't care about
67
+ // flash-of-unstyled-content issues in development.
68
+ {
69
+ test: /(.scss|.css)$/,
70
+ use: [
71
+ 'style-loader', // creates style nodes from JS strings
72
+ {
73
+ loader: 'css-loader', // translates CSS into CommonJS
74
+ options: {
75
+ sourceMap: true,
76
+ modules: {
77
+ compileType: 'icss',
78
+ },
79
+ },
80
+ },
81
+ {
82
+ loader: 'postcss-loader',
83
+ options: {
84
+ postcssOptions: {
85
+ plugins: [
86
+ PostCssAutoprefixerPlugin(),
87
+ PostCssRTLCSS(),
88
+ PostCssCustomMediaCSS(),
89
+ ],
90
+ },
91
+ },
92
+ },
93
+ 'resolve-url-loader',
94
+ {
95
+ loader: 'sass-loader', // compiles Sass to CSS
96
+ options: {
97
+ sourceMap: true,
98
+ sassOptions: {
99
+ includePaths: [
100
+ path.join(process.cwd(), 'node_modules'),
101
+ path.join(process.cwd(), 'src'),
102
+ ],
103
+ // silences compiler warnings regarding deprecation warnings
104
+ quietDeps: true,
105
+ },
106
+ },
107
+ },
108
+ ],
109
+ },
110
+ {
111
+ test: /.svg(\?v=\d+\.\d+\.\d+)?$/,
112
+ issuer: /\.jsx?$/,
113
+ use: ['@svgr/webpack'],
114
+ },
115
+ // Webpack, by default, uses the url-loader for images and fonts that are required/included by
116
+ // files it processes, which just base64 encodes them and inlines them in the javascript
117
+ // bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
118
+ // file-loader instead to copy the files directly to the output directory.
119
+ {
120
+ test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
121
+ loader: 'file-loader',
122
+ },
123
+ {
124
+ test: /favicon.ico$/,
125
+ loader: 'file-loader',
126
+ options: {
127
+ name: '[name].[ext]', // <-- retain original file name
128
+ },
129
+ },
130
+ {
131
+ test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
132
+ loader: 'file-loader',
133
+ },
134
+ ],
135
+ },
136
+ optimization: {
137
+ minimizer: [
138
+ '...',
139
+ new ImageMinimizerPlugin({
140
+ implementation: ImageMinimizerPlugin.sharpMinify,
141
+ options: {
142
+ encodeOptions: {
143
+ ...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
144
+ { ...accumulator, [value]: { progressive: true, quality: 65 } }
145
+ ), {}),
146
+ gif: {
147
+ effort: 5,
148
+ },
149
+ },
150
+ },
151
+ }),
152
+ ],
153
+ },
154
+ // Specify additional processing or side-effects done on the Webpack output bundles as a whole.
155
+ plugins: [
156
+ // Generates an HTML file in the output directory.
157
+ new HtmlWebpackPlugin({
158
+ inject: true, // Appends script tags linking to the webpack bundles at the end of the body
159
+ template: path.resolve(process.cwd(), 'public/index.html'),
160
+ FAVICON_URL: process.env.FAVICON_URL || null,
161
+ OPTIMIZELY_PROJECT_ID: process.env.OPTIMIZELY_PROJECT_ID || null,
162
+ NODE_ENV: process.env.NODE_ENV || null,
163
+ }),
164
+ new Dotenv({
165
+ path: path.resolve(process.cwd(), '.env.development-stage'),
166
+ systemvars: true,
167
+ }),
168
+ new ReactRefreshWebpackPlugin(),
169
+ ],
170
+ // This configures webpack-dev-server which serves bundles from memory and provides live
171
+ // reloading.
172
+ devServer: {
173
+ host: '0.0.0.0',
174
+ port: process.env.PORT || 8080,
175
+ https: true,
176
+ historyApiFallback: {
177
+ index: path.join(PUBLIC_PATH, 'index.html'),
178
+ disableDotRule: true,
179
+ },
180
+ // Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
181
+ // for the WebpackDevServer client so it can learn when the files were
182
+ // updated. The WebpackDevServer client is included as an entry point
183
+ // in the webpack development configuration. Note that only changes
184
+ // to CSS are currently hot reloaded. JS changes will refresh the browser.
185
+ hot: true,
186
+ webSocketServer: 'ws',
187
+ devMiddleware: {
188
+ publicPath: PUBLIC_PATH,
189
+ },
190
+ },
191
+ });
@@ -0,0 +1,193 @@
1
+ // This is the dev Webpack config. All settings here should prefer a fast build
2
+ // time at the expense of creating larger, unoptimized bundles.
3
+ const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
4
+
5
+ const { merge } = require('webpack-merge');
6
+ const Dotenv = require('dotenv-webpack');
7
+ const dotenv = require('dotenv');
8
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
9
+ const path = require('path');
10
+ const PostCssAutoprefixerPlugin = require('autoprefixer');
11
+ const PostCssRTLCSS = require('postcss-rtlcss');
12
+ const PostCssCustomMediaCSS = require('postcss-custom-media');
13
+ const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
14
+
15
+ const commonConfig = require('./webpack.common.config');
16
+ const presets = require('../lib/presets');
17
+ const resolvePrivateEnvConfig = require('../lib/resolvePrivateEnvConfig');
18
+ const getLocalAliases = require('./getLocalAliases');
19
+
20
+ // Add process env vars. Currently used only for setting the
21
+ // server port and the publicPath
22
+ dotenv.config({
23
+ path: path.resolve(process.cwd(), '.env.development'),
24
+ });
25
+
26
+ // Allow private/local overrides of env vars from .env.development for config settings
27
+ // that you'd like to persist locally during development, without the risk of checking
28
+ // in temporary modifications to .env.development.
29
+ resolvePrivateEnvConfig('.env.private');
30
+
31
+ const aliases = getLocalAliases();
32
+ const PUBLIC_PATH = process.env.PUBLIC_PATH || '/';
33
+
34
+ module.exports = merge(commonConfig, {
35
+ mode: 'development',
36
+ devtool: 'eval-source-map',
37
+ output: {
38
+ publicPath: PUBLIC_PATH,
39
+ },
40
+ resolve: {
41
+ alias: aliases,
42
+ extensions: ['.js', '.jsx', '.ts', '.tsx'],
43
+ },
44
+ module: {
45
+ // Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
46
+ rules: [
47
+ // The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
48
+ // Babel is configured with the .babelrc file at the root of the project.
49
+ {
50
+ test: /\.(js|jsx|ts|tsx)$/,
51
+ exclude: /node_modules\/(?!@(open)?edx)/,
52
+ use: {
53
+ loader: 'babel-loader',
54
+ options: {
55
+ configFile: presets['babel-typescript'].resolvedFilepath,
56
+ // Caches result of loader to the filesystem. Future builds will attempt to read
57
+ // from the cache to avoid needing to run the expensive recompilation process
58
+ // on each run.
59
+ cacheDirectory: true,
60
+ plugins: [
61
+ require.resolve('react-refresh/babel'),
62
+ ],
63
+ },
64
+ },
65
+ },
66
+ // We are not extracting CSS from the javascript bundles in development because extracting
67
+ // prevents hot-reloading from working, it increases build time, and we don't care about
68
+ // flash-of-unstyled-content issues in development.
69
+ {
70
+ test: /(.scss|.css)$/,
71
+ use: [
72
+ 'style-loader', // creates style nodes from JS strings
73
+ {
74
+ loader: 'css-loader', // translates CSS into CommonJS
75
+ options: {
76
+ sourceMap: true,
77
+ modules: {
78
+ compileType: 'icss',
79
+ },
80
+ },
81
+ },
82
+ {
83
+ loader: 'postcss-loader',
84
+ options: {
85
+ postcssOptions: {
86
+ plugins: [
87
+ PostCssAutoprefixerPlugin(),
88
+ PostCssRTLCSS(),
89
+ PostCssCustomMediaCSS(),
90
+ ],
91
+ },
92
+ },
93
+ },
94
+ 'resolve-url-loader',
95
+ {
96
+ loader: 'sass-loader', // compiles Sass to CSS
97
+ options: {
98
+ sourceMap: true,
99
+ sassOptions: {
100
+ includePaths: [
101
+ path.join(process.cwd(), 'node_modules'),
102
+ path.join(process.cwd(), 'src'),
103
+ ],
104
+ // silences compiler warnings regarding deprecation warnings
105
+ quietDeps: true,
106
+ },
107
+ },
108
+ },
109
+ ],
110
+ },
111
+ {
112
+ test: /.svg(\?v=\d+\.\d+\.\d+)?$/,
113
+ issuer: /\.jsx?$/,
114
+ use: ['@svgr/webpack'],
115
+ },
116
+ // Webpack, by default, uses the url-loader for images and fonts that are required/included by
117
+ // files it processes, which just base64 encodes them and inlines them in the javascript
118
+ // bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
119
+ // file-loader instead to copy the files directly to the output directory.
120
+ {
121
+ test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
122
+ loader: 'file-loader',
123
+ },
124
+ {
125
+ test: /favicon.ico$/,
126
+ loader: 'file-loader',
127
+ options: {
128
+ name: '[name].[ext]', // <-- retain original file name
129
+ },
130
+ },
131
+ {
132
+ test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
133
+ loader: 'file-loader',
134
+ },
135
+ ],
136
+ },
137
+ optimization: {
138
+ minimizer: [
139
+ '...',
140
+ new ImageMinimizerPlugin({
141
+ minimizer: {
142
+ implementation: ImageMinimizerPlugin.sharpMinify,
143
+ options: {
144
+ encodeOptions: {
145
+ ...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
146
+ { ...accumulator, [value]: { progressive: true, quality: 65 } }
147
+ ), {}),
148
+ gif: {
149
+ effort: 5,
150
+ },
151
+ },
152
+ },
153
+ },
154
+ }),
155
+ ],
156
+ },
157
+ // Specify additional processing or side-effects done on the Webpack output bundles as a whole.
158
+ plugins: [
159
+ // Generates an HTML file in the output directory.
160
+ new HtmlWebpackPlugin({
161
+ inject: true, // Appends script tags linking to the webpack bundles at the end of the body
162
+ template: path.resolve(process.cwd(), 'public/index.html'),
163
+ FAVICON_URL: process.env.FAVICON_URL || null,
164
+ OPTIMIZELY_PROJECT_ID: process.env.OPTIMIZELY_PROJECT_ID || null,
165
+ NODE_ENV: process.env.NODE_ENV || null,
166
+ }),
167
+ new Dotenv({
168
+ path: path.resolve(process.cwd(), '.env.development'),
169
+ systemvars: true,
170
+ }),
171
+ new ReactRefreshWebpackPlugin(),
172
+ ],
173
+ // This configures webpack-dev-server which serves bundles from memory and provides live
174
+ // reloading.
175
+ devServer: {
176
+ host: '0.0.0.0',
177
+ port: process.env.PORT || 8080,
178
+ historyApiFallback: {
179
+ index: path.join(PUBLIC_PATH, 'index.html'),
180
+ disableDotRule: true,
181
+ },
182
+ // Enable hot reloading server. It will provide WDS_SOCKET_PATH endpoint
183
+ // for the WebpackDevServer client so it can learn when the files were
184
+ // updated. The WebpackDevServer client is included as an entry point
185
+ // in the webpack development configuration. Note that only changes
186
+ // to CSS are currently hot reloaded. JS changes will refresh the browser.
187
+ hot: true,
188
+ webSocketServer: 'ws',
189
+ devMiddleware: {
190
+ publicPath: PUBLIC_PATH,
191
+ },
192
+ },
193
+ });
@@ -0,0 +1,219 @@
1
+ // This is the prod Webpack config. All settings here should prefer smaller,
2
+ // optimized bundles at the expense of a longer build time.
3
+
4
+ const ImageMinimizerPlugin = require('image-minimizer-webpack-plugin');
5
+ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
6
+ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
7
+ const { merge } = require('webpack-merge');
8
+ const CssNano = require('cssnano');
9
+ const Dotenv = require('dotenv-webpack');
10
+ const dotenv = require('dotenv');
11
+ const NewRelicSourceMapPlugin = require('@edx/new-relic-source-map-webpack-plugin');
12
+ const HtmlWebpackPlugin = require('html-webpack-plugin');
13
+ const MiniCssExtractPlugin = require('mini-css-extract-plugin');
14
+ const path = require('path');
15
+ const PostCssAutoprefixerPlugin = require('autoprefixer');
16
+ const PostCssRTLCSS = require('postcss-rtlcss');
17
+ const PostCssCustomMediaCSS = require('postcss-custom-media');
18
+
19
+ // Reduce CSS file size by ~70%
20
+ const purgecss = require('@fullhuman/postcss-purgecss');
21
+
22
+ const HtmlWebpackNewRelicPlugin = require('../lib/plugins/html-webpack-new-relic-plugin');
23
+ const commonConfig = require('./webpack.common.config');
24
+ const presets = require('../lib/presets');
25
+
26
+ // Add process env vars. Currently used only for setting the PUBLIC_PATH.
27
+ dotenv.config({
28
+ path: path.resolve(process.cwd(), '.env'),
29
+ });
30
+
31
+ const extraPostCssPlugins = [];
32
+ if (process.env.USE_PURGECSS) { // If USE_PURGECSS is set we append it.
33
+ extraPostCssPlugins.push(purgecss({
34
+ content: ['./**/*.html', './**/*.js', './**/*.jsx', './**/*.ts', './**/*.tsx'],
35
+ }));
36
+ }
37
+ const extraPlugins = [];
38
+ if (process.env.ENABLE_NEW_RELIC !== 'false') {
39
+ // Enable NewRelic logging only if the account ID is properly defined
40
+ extraPlugins.push(new HtmlWebpackNewRelicPlugin({
41
+ // This plugin fixes an issue where the newrelic script will break if
42
+ // not added directly to the HTML.
43
+ // We use non empty strings as defaults here to prevent errors for empty configs
44
+ accountID: process.env.NEW_RELIC_ACCOUNT_ID || 'undefined_account_id',
45
+ agentID: process.env.NEW_RELIC_AGENT_ID || 'undefined_agent_id',
46
+ trustKey: process.env.NEW_RELIC_TRUST_KEY || 'undefined_trust_key',
47
+ licenseKey: process.env.NEW_RELIC_LICENSE_KEY || 'undefined_license_key',
48
+ applicationID: process.env.NEW_RELIC_APP_ID || 'undefined_application_id',
49
+ }));
50
+ extraPlugins.push(new NewRelicSourceMapPlugin({
51
+ applicationId: process.env.NEW_RELIC_APP_ID,
52
+ apiKey: process.env.NEW_RELIC_ADMIN_KEY,
53
+ staticAssetUrl: process.env.BASE_URL,
54
+ // upload source maps in prod builds only
55
+ noop: typeof process.env.NEW_RELIC_ADMIN_KEY === 'undefined',
56
+ }));
57
+ }
58
+
59
+ module.exports = merge(commonConfig, {
60
+ mode: 'production',
61
+ devtool: 'source-map',
62
+ output: {
63
+ filename: '[name].[chunkhash].js',
64
+ path: path.resolve(process.cwd(), 'dist'),
65
+ publicPath: process.env.PUBLIC_PATH || '/',
66
+ },
67
+ module: {
68
+ // Specify file-by-file rules to Webpack. Some file-types need a particular kind of loader.
69
+ rules: [
70
+ // The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
71
+ // Babel is configured with the .babelrc file at the root of the project.
72
+ {
73
+ test: /\.(js|jsx)$/,
74
+ exclude: /node_modules\/(?!@(open)?edx)/,
75
+ use: {
76
+ loader: 'babel-loader',
77
+ options: {
78
+ configFile: presets.babel.resolvedFilepath,
79
+ },
80
+ },
81
+ },
82
+ {
83
+ test: /\.js$/,
84
+ use: ['source-map-loader'],
85
+ enforce: 'pre',
86
+ },
87
+ // Webpack, by default, includes all CSS in the javascript bundles. Unfortunately, that means:
88
+ // a) The CSS won't be cached by browsers separately (a javascript change will force CSS
89
+ // re-download). b) Since CSS is applied asyncronously, it causes an ugly
90
+ // flash-of-unstyled-content.
91
+ //
92
+ // To avoid these problems, we extract the CSS from the bundles into separate CSS files that
93
+ // can be included as <link> tags in the HTML <head> manually.
94
+ //
95
+ // We will not do this in development because it prevents hot-reloading from working and it
96
+ // increases build time.
97
+ {
98
+ test: /(.scss|.css)$/,
99
+ use: [
100
+ MiniCssExtractPlugin.loader,
101
+ {
102
+ loader: 'css-loader', // translates CSS into CommonJS
103
+ options: {
104
+ sourceMap: true,
105
+ modules: {
106
+ compileType: 'icss',
107
+ },
108
+ },
109
+ },
110
+ {
111
+ loader: 'postcss-loader',
112
+ options: {
113
+ postcssOptions: {
114
+ plugins: [
115
+ PostCssAutoprefixerPlugin(),
116
+ PostCssRTLCSS(),
117
+ CssNano(),
118
+ PostCssCustomMediaCSS(),
119
+ ...extraPostCssPlugins,
120
+ ],
121
+ },
122
+ },
123
+ },
124
+ 'resolve-url-loader',
125
+ {
126
+ loader: 'sass-loader', // compiles Sass to CSS
127
+ options: {
128
+ sourceMap: true,
129
+ sassOptions: {
130
+ includePaths: [
131
+ path.join(process.cwd(), 'node_modules'),
132
+ path.join(process.cwd(), 'src'),
133
+ ],
134
+ // silences compiler warnings regarding deprecation warnings
135
+ quietDeps: true,
136
+ },
137
+ },
138
+ },
139
+ ],
140
+ },
141
+ {
142
+ test: /.svg(\?v=\d+\.\d+\.\d+)?$/,
143
+ issuer: /\.jsx?$/,
144
+ use: ['@svgr/webpack'],
145
+ },
146
+ // Webpack, by default, uses the url-loader for images and fonts that are required/included by
147
+ // files it processes, which just base64 encodes them and inlines them in the javascript
148
+ // bundles. This makes the javascript bundles ginormous and defeats caching so we will use the
149
+ // file-loader instead to copy the files directly to the output directory.
150
+ {
151
+ test: /\.(woff2?|ttf|svg|eot)(\?v=\d+\.\d+\.\d+)?$/,
152
+ loader: 'file-loader',
153
+ },
154
+ {
155
+ test: /favicon.ico$/,
156
+ loader: 'file-loader',
157
+ options: {
158
+ name: '[name].[ext]', // <-- retain original file name
159
+ },
160
+ },
161
+ {
162
+ test: /\.(jpe?g|png|gif)(\?v=\d+\.\d+\.\d+)?$/,
163
+ loader: 'file-loader',
164
+ },
165
+ ],
166
+ },
167
+ // New in Webpack 4. Replaces CommonChunksPlugin. Extract common modules among all chunks to one
168
+ // common chunk and extract the Webpack runtime to a single runtime chunk.
169
+ optimization: {
170
+ runtimeChunk: 'single',
171
+ splitChunks: {
172
+ chunks: 'all',
173
+ },
174
+ minimizer: [
175
+ '...',
176
+ new ImageMinimizerPlugin({
177
+ minimizer: {
178
+ implementation: ImageMinimizerPlugin.sharpMinify,
179
+ options: {
180
+ encodeOptions: {
181
+ ...['png', 'jpeg', 'jpg'].reduce((accumulator, value) => (
182
+ { ...accumulator, [value]: { progressive: true, quality: 65 } }
183
+ ), {}),
184
+ gif: {
185
+ effort: 5,
186
+ },
187
+ },
188
+ },
189
+ },
190
+ }),
191
+ ],
192
+ },
193
+ // Specify additional processing or side-effects done on the Webpack output bundles as a whole.
194
+ plugins: [
195
+ // Cleans the dist directory before each build
196
+ new CleanWebpackPlugin(),
197
+ // Writes the extracted CSS from each entry to a file in the output directory.
198
+ new MiniCssExtractPlugin({
199
+ filename: '[name].[chunkhash].css',
200
+ }),
201
+ // Generates an HTML file in the output directory.
202
+ new HtmlWebpackPlugin({
203
+ inject: true, // Appends script tags linking to the webpack bundles at the end of the body
204
+ template: path.resolve(process.cwd(), 'public/index.html'),
205
+ FAVICON_URL: process.env.FAVICON_URL || null,
206
+ OPTIMIZELY_PROJECT_ID: process.env.OPTIMIZELY_PROJECT_ID || null,
207
+ NODE_ENV: process.env.NODE_ENV || null,
208
+ }),
209
+ new Dotenv({
210
+ path: path.resolve(process.cwd(), '.env'),
211
+ systemvars: true,
212
+ }),
213
+ new BundleAnalyzerPlugin({
214
+ analyzerMode: 'static',
215
+ openAnalyzer: false,
216
+ }),
217
+ ...extraPlugins,
218
+ ],
219
+ });
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <coverage generated="1702659093483" clover="3.2.0">
3
+ <project timestamp="1702659093483" name="All files">
4
+ <metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
5
+ </project>
6
+ </coverage>
@@ -0,0 +1 @@
1
+ {}