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
Copy file name to clipboardExpand all lines: website/docs/introduction/docusaurus-usage.md
+27-9Lines changed: 27 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,31 +25,49 @@ export default function Root({ children }) {
25
25
26
26
You can override the default CodeBlock by swizzling the component, [more about swizzling](https://docusaurus.io/docs/swizzling).
27
27
28
-
For a full example, check out an example of a Docusaurus site using `react-py` at https://github.com/James-Ansley/python-docusaurus-template, specifically `src/theme/CodeBlock` and `src/components/CodeEditor`.
28
+
For a full example, check out an example of a Docusaurus site using `react-py` at https://github.com/elilambnz/python-docusaurus-template, specifically `src/theme/CodeBlock` and `src/components/CodeEditor`.
29
29
30
30
## Docusaurus config
31
31
32
32
We've encountered a Webpack issue when bundling a Docusaurus site with this package. The following plugin can be added to `docusaurus.config.js` to resolve this issue:
33
33
34
34
```js
35
35
plugins: [
36
-
asyncfunctiondisableUsedExports() {
36
+
asyncfunctionreactPyWebpackFix() {
37
37
return {
38
-
name:'disable-used-exports',
39
-
configureWebpack() {
38
+
name:'react-py-webpack-fix',
39
+
configureWebpack(_config, isServer) {
40
+
if (isServer) return {}
41
+
40
42
return {
41
-
optimization: {
42
-
usedExports:false
43
-
}
43
+
// Add webpack globals to all chunks to fix worker context issues
44
+
// This resolves the "__webpack_require__ is not defined" error in web workers
45
+
plugins: [
46
+
new (require('webpack').BannerPlugin)({
47
+
banner:`
48
+
if (typeof __webpack_require__ === 'undefined') {
49
+
var __webpack_require__ = {
50
+
gca: function(e) { return e = {}[e] || e, __webpack_require__.p + __webpack_require__.u(e); },
51
+
p: '',
52
+
u: function(e) { return ''; }
53
+
};
54
+
}
55
+
`,
56
+
raw:true,
57
+
test:/\.js$/
58
+
})
59
+
]
44
60
}
45
61
}
46
62
}
47
63
}
48
64
]
49
65
```
50
66
51
-
[Read more about this issue here](https://github.com/facebook/docusaurus/issues/8389).
67
+
This configuration resolves the `__webpack_require__ is not defined` error that occurs when web workers are processed by webpack. The BannerPlugin injects the necessary webpack globals into all JavaScript chunks, ensuring that worker files have access to the `__webpack_require__` object they expect.
68
+
69
+
[Read more about the original issue here](https://github.com/facebook/docusaurus/issues/8389).
52
70
53
71
## Python Docusaurus Template
54
72
55
-
Get started with `react-py` and Docusaurus, you can use the [Python Docusaurus Template](https://github.com/James-Ansley/python-docusaurus-template). Click the green "Use this template" button on the repository page to clone, then follow the Docusaurus configuration steps for your specific site.
73
+
Get started with `react-py` and Docusaurus, you can use the [Python Docusaurus Template](https://github.com/elilambnz/python-docusaurus-template). Click the green "Use this template" button on the repository page to clone, then follow the Docusaurus configuration steps for your specific site.
0 commit comments