Skip to content

Commit

Permalink
Merge pull request #69 from plesk/fix-custom-config-routes
Browse files Browse the repository at this point in the history
Fix routes add on overwrite from custom config
  • Loading branch information
justillusion authored Dec 8, 2022
2 parents 301df21 + e1dd2b2 commit 88c5f6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions lib/webpack/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ module.exports = ({ isDev }) => {
const output = resolveAppPath('src/htdocs/dist');
const extensionConfig = loadExtensionConfig();
const routes = prepareRoutes(extensionConfig.routes);

const routesPlugin = new VirtualModulesPlugin({
routes: generateRoutesModule(routes),
});

const baseConfig = {
mode: isDev ? 'development' : 'production',
watch: isDev,
Expand Down Expand Up @@ -91,9 +96,6 @@ module.exports = ({ isDev }) => {
routes,
},
}),
new VirtualModulesPlugin({
routes: generateRoutesModule(routes),
}),
],
resolve: {
modules: [
Expand All @@ -106,5 +108,12 @@ module.exports = ({ isDev }) => {
},
};

return applyCustomConfig(baseConfig, { isDev }, extensionConfig.webpack);
const config = applyCustomConfig(baseConfig, { isDev }, extensionConfig.webpack);

if (!config.plugins || !config.plugins.find(plugin => plugin?.constructor?.name === 'VirtualModulesPlugin')) {
config.plugins ??= [];
config.plugins.push(routesPlugin);
}

return config;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@plesk/plesk-ext-sdk",
"description": "Plesk Extension SDK",
"version": "0.6.1",
"version": "0.6.2",
"author": "Plesk Developers <[email protected]> (https://www.plesk.com/)",
"repository": "plesk/plesk-ext-sdk",
"bugs": {
Expand Down

0 comments on commit 88c5f6b

Please sign in to comment.