You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The migration howto was missing the @src alias in jest configuration,
since it's no longer provided by the default in frontend-base.
Add the finding that `tsc-alias` needs to be called after assets are
copied.
Finally, document the fix to the site.config.test.tsx circular dependency
when mocking `@openedx/frontend-base` itself.
Copy file name to clipboardExpand all lines: docs/how_tos/migrate-frontend-app.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,23 +156,25 @@ Also:
156
156
> **Why change `fedx-scripts` to `openedx`?**
157
157
> A few reasons. One, the Open edX project shouldn't be using the name of an internal community of practice at edX for its frontend tooling. Two, some dependencies of your MFE invariably still use frontend-build for their own build needs. This means that they already installed `fedx-scripts` into your `node_modules/.bin` folder. Only one version can be in there, so we need a new name. Seemed like a great time for a naming refresh. |
158
158
159
-
Last but not least, add `clean:` and `build:` targets to your `Makefile`. The build target compiles TypeScript to JavaScript, uses `tsc-alias` to rewrite `@src` path aliases to relative paths, and copies all SCSS files from `src/` into `dist/` preserving directory structure:
159
+
Last but not least, add `clean:` and `build:` targets to your `Makefile`. The build target compiles TypeScript to JavaScript, copies all SCSS and asset files from `src/` into `dist/` preserving directory structure, and finally uses `tsc-alias` to rewrite `@src` path aliases to relative paths:
160
160
161
161
```makefile
162
162
clean:
163
163
rm -rf dist
164
164
165
165
build: clean
166
166
tsc --project tsconfig.build.json
167
-
tsc-alias -p tsconfig.build.json
168
-
find src -type f -name '*.scss' -exec sh -c '\
167
+
find src -type f \( -name '*.scss' -o -path '*/assets/*'\) -exec sh -c '\
169
168
forfin"$$@";do \
170
169
d="dist/$${f#src/}";\
171
170
mkdir -p "$$(dirname "$$d")";\
172
171
cp "$$f""$$d";\
173
172
done' sh {} +
173
+
tsc-alias -p tsconfig.build.json
174
174
```
175
175
176
+
Note that the `find` command copies all files under `assets/` directories regardless of type, so you don't need to enumerate asset extensions. Also note that `tsc-alias` runs after the copy step so that it can resolve `@src` aliases pointing to asset files. If it ran before, it wouldn't find them and would omit them from the relative path conversion.
Jest test suites that test React components that import SVG and files must add mocks for those filetypes. This can be accomplished by adding the following module name mappers to jest.config.js:
377
+
Jest test suites that test React components that import SVG and other assets (such as PNGs) must add mocks for those filetypes. This can be accomplished by adding module name mappers to jest.config.js. Just make sure they come before the `@src` alias, which must also be added here if you're using it:
0 commit comments