diff --git a/generators/angular/__snapshots__/generator.spec.ts.snap b/generators/angular/__snapshots__/generator.spec.ts.snap index 6f12d4c2646..7651b2ffc83 100644 --- a/generators/angular/__snapshots__/generator.spec.ts.snap +++ b/generators/angular/__snapshots__/generator.spec.ts.snap @@ -702,7 +702,6 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa "dependencies": {}, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "webpack-bundle-analyzer": null, @@ -710,7 +709,6 @@ exports[`generator - angular gateway-jwt-skipUserManagement(true)-withAdminUi(fa "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, @@ -1645,7 +1643,6 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend }, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "folder-hash": null, @@ -1655,7 +1652,6 @@ exports[`generator - angular gateway-oauth2-withAdminUi(true)-skipJhipsterDepend "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, @@ -2349,7 +2345,6 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi "dependencies": {}, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "webpack-bundle-analyzer": null, @@ -2357,10 +2352,17 @@ exports[`generator - angular microservice-jwt-skipUserManagement(false)-withAdmi "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, + { + "devDependencies": { + "browser-sync-webpack-plugin": null, + }, + "overrides": { + "browser-sync": "BROWSER_SYNC_VERSION", + }, + }, ], } `; @@ -3059,7 +3061,6 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD }, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "folder-hash": null, @@ -3069,10 +3070,17 @@ exports[`generator - angular microservice-oauth2-withAdminUi(true)-skipJhipsterD "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, + { + "devDependencies": { + "browser-sync-webpack-plugin": null, + }, + "overrides": { + "browser-sync": "BROWSER_SYNC_VERSION", + }, + }, ], } `; @@ -4172,7 +4180,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi( }, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "folder-hash": null, @@ -4182,7 +4189,6 @@ exports[`generator - angular monolith-jwt-skipUserManagement(false)-withAdminUi( "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, @@ -4862,7 +4868,6 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe "dependencies": {}, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "webpack-bundle-analyzer": null, @@ -4870,7 +4875,6 @@ exports[`generator - angular monolith-oauth2-withAdminUi(false)-skipJhipsterDepe "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, @@ -5559,7 +5563,6 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin "dependencies": {}, "devDependencies": { "@angular-builders/custom-webpack": null, - "browser-sync-webpack-plugin": null, "copy-webpack-plugin": null, "eslint-webpack-plugin": null, "webpack-bundle-analyzer": null, @@ -5567,7 +5570,6 @@ exports[`generator - angular monolith-session-skipUserManagement(true)-withAdmin "webpack-notifier": null, }, "overrides": { - "browser-sync": "BROWSER_SYNC_VERSION", "webpack": "WEBPACK_VERSION", }, }, diff --git a/generators/angular/generator.ts b/generators/angular/generator.ts index 70f047f473d..49796ae68a6 100644 --- a/generators/angular/generator.ts +++ b/generators/angular/generator.ts @@ -176,7 +176,7 @@ export default class AngularGenerator extends BaseApplicationGenerator +<%_ if (microfrontend) { _%> const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); +<%_ } _%> const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer'); const WebpackNotifierPlugin = require('webpack-notifier'); const CopyWebpackPlugin = require('copy-webpack-plugin'); @@ -32,6 +34,7 @@ const ESLintPlugin = require('eslint-webpack-plugin'); const environment = require('./environment'); const proxyConfig = require('./proxy.conf'); +// eslint-disable-next-line no-unused-vars module.exports = async (config, options, targetOptions) => { <%_ if (enableTranslation) { _%> const languagesHash = await hashElement(path.resolve(__dirname, '<%= this.relativeDir(clientRootDir + 'webpack/', clientSrcDir) %>i18n'), { @@ -60,6 +63,7 @@ module.exports = async (config, options, targetOptions) => { if (config.devServer) { config.devServer.proxy = proxyConfig({ tls }); } +<%_ if (microfrontend) { _%> if (targetOptions.target === 'serve' || config.watch) { config.plugins.push( @@ -102,6 +106,7 @@ module.exports = async (config, options, targetOptions) => { ), ); } +<%_ } _%> if (config.mode === 'production') { config.plugins.push( diff --git a/generators/app/__snapshots__/generator.spec.ts.snap b/generators/app/__snapshots__/generator.spec.ts.snap index fb493a56345..07bd5cd0b42 100644 --- a/generators/app/__snapshots__/generator.spec.ts.snap +++ b/generators/app/__snapshots__/generator.spec.ts.snap @@ -329,7 +329,7 @@ exports[`generator - app with default config should match snapshot 1`] = ` "devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster", "devR2dbcUrl": undefined, "devServerPort": 4200, - "devServerPortProxy": 9000, + "devServerPortProxy": undefined, "dockerContainers": { "apache/kafka-native": "apache-kafka-native-placeholder", "apachepulsar/pulsar": "apachepulsar-pulsar-placeholder", @@ -998,7 +998,7 @@ exports[`generator - app with gateway should match snapshot 1`] = ` "devLiquibaseUrl": "jdbc:postgresql://localhost:5432/jhipster", "devR2dbcUrl": "r2dbc:postgresql://localhost:5432/jhipster", "devServerPort": 4200, - "devServerPortProxy": 9000, + "devServerPortProxy": undefined, "dockerContainers": { "apache/kafka-native": "apache-kafka-native-placeholder", "apachepulsar/pulsar": "apachepulsar-pulsar-placeholder", diff --git a/generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap b/generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap index 34e6a3feb2c..9f3454782b2 100644 --- a/generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap +++ b/generators/kubernetes/__snapshots__/kubernetes.spec.ts.snap @@ -3536,7 +3536,7 @@ data: "redirectUris": [ "http://jhgate.default.example.com/*", "https://jhgate.default.example.com/*", "http://localhost:8080/*", - "https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*", + "https://localhost:8080/*","http://localhost:4200/*", "http://localhost:8100/*", "http://127.0.0.1:8761/*", "dev.localhost.ionic:*" @@ -3544,7 +3544,7 @@ data: "webOrigins": [ "http://jhgate.default.example.com", "https://jhgate.default.example.com", "http://localhost:8080", - "https://localhost:8080","http://localhost:4200", "http://localhost:9000", + "https://localhost:8080","http://localhost:4200", "http://localhost:8100", "http://127.0.0.1:8761" ], @@ -6969,7 +6969,7 @@ data: "redirectUris": [ "http://jhgate.default.example.com/*", "https://jhgate.default.example.com/*", "http://localhost:8080/*", - "https://localhost:8080/*","http://localhost:4200/*", "http://localhost:9000/*", + "https://localhost:8080/*","http://localhost:4200/*", "http://localhost:8100/*", "http://127.0.0.1:8761/*", "dev.localhost.ionic:*" @@ -6977,7 +6977,7 @@ data: "webOrigins": [ "http://jhgate.default.example.com", "https://jhgate.default.example.com", "http://localhost:8080", - "https://localhost:8080","http://localhost:4200", "http://localhost:9000", + "https://localhost:8080","http://localhost:4200", "http://localhost:8100", "http://127.0.0.1:8761" ], diff --git a/generators/workspaces/generator.ts b/generators/workspaces/generator.ts index ef6f440a4e0..3328669a698 100644 --- a/generators/workspaces/generator.ts +++ b/generators/workspaces/generator.ts @@ -187,19 +187,22 @@ export default class WorkspacesGenerator extends BaseWorkspacesGenerator { if (applications.some(app => app.clientFrameworkAngular)) { const { - dependencies: { rxjs }, devDependencies: { webpack: webpackVersion, 'browser-sync': browserSyncVersion }, } = this.fs.readJSON(this.fetchFromInstalledJHipster(GENERATOR_ANGULAR, 'resources', 'package.json')); this.packageJson.merge({ - devDependencies: { - rxjs, // Set version to workaround https://github.com/npm/cli/issues/4437 - }, overrides: { - 'browser-sync': browserSyncVersion, webpack: webpackVersion, }, }); + + if (applications.some(app => app.microfrontend)) { + this.packageJson.merge({ + overrides: { + 'browser-sync': browserSyncVersion, + }, + }); + } } if (applications.some(app => app.backendTypeJavaAny)) { diff --git a/lib/jhipster/default-application-options.ts b/lib/jhipster/default-application-options.ts index cf8d4ebf80e..27a19db4095 100644 --- a/lib/jhipster/default-application-options.ts +++ b/lib/jhipster/default-application-options.ts @@ -110,7 +110,7 @@ export function getConfigForClientApplication(options: ApplicationDefaults = {}) return options; } if (options[OptionNames.MICROFRONTEND] === undefined) { - options[OptionNames.MICROFRONTEND] = Boolean(options[OptionNames.MICROFRONTENDS]?.length); + options[OptionNames.MICROFRONTEND] = Boolean(options[OptionNames.MICROFRONTENDS]?.length) || options.applicationType === 'microservice'; } if (!options[CLIENT_THEME]) { options[CLIENT_THEME] = OptionValues[CLIENT_THEME]; @@ -130,7 +130,8 @@ export function getConfigForClientApplication(options: ApplicationDefaults = {}) } else { options.devServerPort ??= 9060; } - options.devServerPortProxy ??= options.clientBundler === 'webpack' ? 9000 : undefined; + options.devServerPortProxy ??= + options.clientBundler === 'webpack' && (clientFramework !== 'angular' || options.microfrontend) ? 9000 : undefined; return options; }