Replies: 2 comments 3 replies
-
|
Please create a simple repro:
It's hard to understand what you are trying to do here and what problems you encounter. Also it's hard to understand why you want certain things, like changing the location of |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
I wrote a simple plugin to solve problem one. The main reason for problem 1 is the configuration path of babel and the path problem when webpack resolves dependencies const {
mergeWithCustomize,
customizeArray,
customizeObject,
} = require("webpack-merge");
const fs = require("fs");
const resolve = {
src: (relativePath) => {
const p = path.resolve(__dirname, relativePath);
return p;
},
realpath: (dir = ".") => fs.realpathSync(dir),
};
function excludeJsRule(rules) {
return Array.from(rules || [])?.filter(
(role) => !String(role.test).includes("sx")
);
}
function writeFile(isServer, content) {
const fileName = `./.runtime.webpack.${isServer}.js`;
fs.writeFile(
resolve.app(fileName),
`module.exports=${JSON.stringify(
content,
(k, v) => (v instanceof RegExp ? v.source : v),
"\t"
)}`,
{ flag: "w+" },
(e) => e && console.error("write into %s failed!", fileName)
);
}
module.exports = function (context, options) {
const debug = options.debugger ?? false;
return {
name: "dependencies-resolver",
configureWebpack(config, isServer, utils) {
const rules = excludeJsRule(config?.module?.rules);
const returnedConfig = {
mergeStrategy: {
"module.rules": "replace",
"resolve.modules": "replace",
"resolveLoader.modules": "replace",
},
resolve: {
fallback: {
"@mdx-js": resolve.src("./node_modules/@mdx-js"),
},
modules: [
resolve.src("./node_modules"),
resolve.src("./node_modules/@docusaurus/core/node_modules"),
],
},
resolveLoader: {
modules: [resolve.src("./node_modules")],
},
module: {
rules: [
{
test: /\.(j|t)sx?$/,
use: {
loader: require.resolve("./node_modules/babel-loader"),
options: {
babelrc: false,
cwd: resolve.src("."),
configFile: resolve.src("./babel.config.js"),
caller: { name: isServer ? "server" : "client" },
},
},
},
...rules,
],
},
};
if (debug) {
writeFile(
isServer,
mergeWithCustomize({
// @ts-ignore
customizeObject: customizeObject(returnedConfig.mergeStrategy),
// @ts-ignore
customizeArray: customizeArray(returnedConfig.mergeStrategy),
})(config, returnedConfig)
);
}
return returnedConfig;
},
};
};Now only problem 3 remains, and it seems that it cannot be modified through the application layer |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
our structure:
There are 3 problems (1 solved):
doc-genproject depends onreactand@mdx-react, but now an error will be reported under theprojectproject, indicating thatreactand@mdx-reactare not installed.DOCUSAURUS_GENERATED_FILES_DIR_NAMEdoesn't seem to work. I want the output directory to beproject/node_modules/doc-gen/.docusaurus, now it will always be generated inproject/.docusaurusupdate:
staticDirectories supports, require a abspath.
Beta Was this translation helpful? Give feedback.
All reactions