Skip to content

Commit

Permalink
add simple config
Browse files Browse the repository at this point in the history
  • Loading branch information
William Marques committed Oct 5, 2019
1 parent 0645f3c commit 7c76001
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
36 changes: 36 additions & 0 deletions generators/client/templates/angular/angular.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,42 @@
"root": "",
"sourceRoot": "<%= MAIN_SRC_DIR.replace(/\/$/, "") %>",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./webpack/webpack.custom.js"
},
"outputPath": "dist/example-ng-app",
"index": "src/main/webapp/index.html",
"main": "src/main/webapp/app/app.main.ts",
"polyfills": "src/main/webapp/app/polyfills.ts",
"tsConfig": "tsconfig.json",
"aot": false,
"assets": [
"src/main/webapp/content",
"src/main/webapp/favicon.ico",
{ "glob": "{css,lib}/*", "input": "./node_modules/swagger-ui/dist", "output": "swagger-ui/dist" },
{
"glob": "swagger-ui.min.js",
"input": "./node_modules/swagger-ui/dist/",
"output": "swagger-ui/dist/"
},
{ "glob": "**/*", "input": "./src/main/webapp/swagger-ui/", "output": "swagger-ui" }
],
"styles": ["src/main/webapp/content/scss/global.scss", "src/main/webapp/content/scss/vendor.scss"],
"scripts": []
}
},
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "jhipster:build",
"proxyConfig": "./webpack/proxy.conf.js"
}
}
},
"schematics": {
"@schematics/angular:component": {
"skipTests": true,
Expand Down
2 changes: 2 additions & 0 deletions generators/client/templates/angular/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
"zone.js": "0.10.2"
},
"devDependencies": {
"@angular-builders/custom-webpack": "^8.2.0",
"@angular-devkit/build-angular": "^0.803.3",
"@angular/cli": "8.3.1",
"@angular/compiler-cli": "8.2.4",
"@ngtools/webpack": "8.3.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
-%>
import 'core-js/proposals/reflect-metadata';
import 'zone.js/dist/zone';
require('../manifest.webapp');
//require('../manifest.webapp');
9 changes: 9 additions & 0 deletions generators/client/templates/angular/webpack/proxy.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const PROXY_CONFIG = [
{
context: ['/api', '/services', '/management', '/swagger-resources', '/v2/api-docs', '/h2-console', '/auth'],
target: `http://localhost:8080`,
secure: false
}
];

module.exports = PROXY_CONFIG;
31 changes: 31 additions & 0 deletions generators/client/templates/angular/webpack/webpack.custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const webpack = require('webpack');
const MergeJsonWebpackPlugin = require('merge-jsons-webpack-plugin');

module.exports = (config, options) => {
console.log(options);
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
BUILD_TIMESTAMP: `'${new Date().getTime()}'`,
// APP_VERSION is passed as an environment variable from the Gradle / Maven build tasks.
VERSION: `'${process.env.hasOwnProperty('APP_VERSION') ? process.env.APP_VERSION : 'DEV'}'`,
// DEBUG_INFO_ENABLED: options.env === 'development',
// The root URL for API calls, ending with a '/' - for example: `"https://www.jhipster.tech:8081/myservice/"`.
// If this URL is left empty (""), then it will be relative to the current context.
// If you use an API server, in `prod` mode, you will need to enable CORS
// (see the `jhipster.cors` common JHipster property in the `application-*.yml` configurations)
SERVER_API_URL: `''`
}
}),
new MergeJsonWebpackPlugin({
output: {
groupBy: [
{ pattern: './src/main/webapp/i18n/en/*.json', fileName: './i18n/en.json' }
// jhipster-needle-i18n-language-webpack - JHipster will add/remove languages in this array
]
}
})
);

return config;
};

0 comments on commit 7c76001

Please sign in to comment.