mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
fix: loading error when running nocobase under subpath (#5924)
* fix: plugin dynamic import should use relative path * fix: output public path * fix(buildPlugin): update public path handling and add custom public path plugin
This commit is contained in:
parent
55c6a5d577
commit
1499caea40
@ -339,7 +339,7 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou
|
||||
path: outDir,
|
||||
filename: outputFileName,
|
||||
chunkFilename: '[chunkhash].js',
|
||||
publicPath: `/static/plugins/${packageJson.name}/dist/client/`,
|
||||
publicPath: `auto`, // will be generated by the custom plugin
|
||||
clean: true,
|
||||
library: {
|
||||
name: packageJson.name,
|
||||
@ -467,14 +467,36 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou
|
||||
new rspack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
}),
|
||||
{
|
||||
apply(compiler) {
|
||||
compiler.hooks.compilation.tap('CustomPublicPathPlugin', (compilation) => {
|
||||
compilation.hooks.runtimeModule.tap('CustomPublicPathPlugin', (module) => {
|
||||
if (module.name === 'auto_public_path') {
|
||||
// 处理所有可能的情况
|
||||
module.source = {
|
||||
source: `
|
||||
__webpack_require__.p = (function() {
|
||||
var publicPath = window['__nocobase_public_path__'] || '/';
|
||||
// 确保路径以 / 结尾
|
||||
if (!publicPath.endsWith('/')) {
|
||||
publicPath += '/';
|
||||
}
|
||||
return publicPath + 'static/plugins/${packageJson.name}/dist/client/';
|
||||
})();`
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
process.env.BUILD_ANALYZE === 'true' &&
|
||||
new RsdoctorRspackPlugin({
|
||||
// plugin options
|
||||
// supports: {
|
||||
// generateTileGraph: true,
|
||||
// },
|
||||
mode: 'brief',
|
||||
}),
|
||||
new RsdoctorRspackPlugin({
|
||||
// plugin options
|
||||
// supports: {
|
||||
// generateTileGraph: true,
|
||||
// },
|
||||
mode: 'brief',
|
||||
}),
|
||||
].filter(Boolean),
|
||||
node: {
|
||||
global: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user