Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to AngularCli and remove all Webpack functions #5661

Closed
wants to merge 11 commits into from
19 changes: 12 additions & 7 deletions generators/client/files-angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@ const files = {
'_tsconfig.json',
'_tsconfig-aot.json',
'_tslint.json',
'_.angular-cli.json',
'webpack/_webpack.common.js',
'webpack/_webpack.dev.js',
'webpack/_webpack.prod.js',
'webpack/_webpack.vendor.js',
{ file: 'webpack/logo-jhipster.png', method: 'copy' }
'_.angular-cli.json'
]
}
],
Expand Down Expand Up @@ -75,6 +70,8 @@ const files = {
]
}
],


image: [
{
path: MAIN_SRC_DIR,
Expand Down Expand Up @@ -105,14 +102,22 @@ const files = {
]
}
],
environments: [
{
path: MAIN_SRC_DIR,
templates: [
'environments/_environment.ts',
'environments/_environment.prod.ts'
]
}
],
angularApp: [
{
path: ANGULAR_DIR,
templates: [
'_app.main.ts',
'_app.route.ts',
'_app.module.ts',
'_app.constants.ts',
'_polyfills.ts',
'_vendor.ts',
'blocks/config/_prod.config.ts',
Expand Down
28 changes: 20 additions & 8 deletions generators/client/templates/angular/_.angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@
},
"apps": [{
"root": "<%= MAIN_SRC_DIR %>",
"outDir": "<%= DIST_DIR %>app",
"outDir": "<%= DIST_DIR %>",
"assets": [
"content",
"content/images",
<%_ if (enableTranslation) { _%>
"i18n",
<%_ } _%>
"favicon.ico"
"favicon.ico",
"swagger-ui",
"robots.txt",
{ "glob": "shim.min.js", "input": "../../../node_modules/core-js/client/", "output": "./" },
{ "glob": "**/*", "input": "../../../node_modules/swagger-ui/dist/", "output": "swagger-ui/dist" }
],
"index": "index.html",
"main": "app/app.main.ts",
"polyfills": "app/polyfills.ts",
"test": "",
"test": "./src/test/javascript/spec/entry.ts",
"tsconfig": "../../../tsconfig.json",
"prefix": "<%= jhiPrefix %>",
"mobile": false,
Expand All @@ -47,7 +51,12 @@
"content/css/global.css"
<%_ } _%>
],
"scripts": []
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}],
"addons": [],
"packages": [],
Expand All @@ -58,11 +67,14 @@
}
},
<%_ } _%>
"lint": [{
"project": "../../../tsconfig.json"
"lint": [
{
"project": "tsconfig.json",
"exclude": "**/node_modules/**/*"
},
{
"project": "../../../tsconfig-aot.json"
"project": "tsconfig-aot.json",
"exclude": "**/node_modules/**/*"
}
],
"test": {
Expand Down
6 changes: 6 additions & 0 deletions generators/client/templates/angular/_bs_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"host": "localhost",
"port": 9000,
"files": ["./target/www/app/**/*.{html,htm,css,js}"],
"server": { "baseDir": "./target/www/app" }
}
100 changes: 27 additions & 73 deletions generators/client/templates/angular/_package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%#
Copyright 2013-2017 the original author or authors from the JHipster project.
Copyright 2013-2017 the original author or authors.

This file is part of the JHipster project, see https://jhipster.github.io/
for more information.
Expand Down Expand Up @@ -53,109 +53,63 @@
"zone.js": "0.8.5"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/cli": "1.0.1",
"@angular/compiler-cli": "4.0.0",
"@types/jasmine": "2.5.47",
"@types/node": "7.0.12",
<%_ if (protractorTests) { _%>
"@types/selenium-webdriver": "2.53.39",
<%_ } _%>
"add-asset-html-webpack-plugin": "1.0.2",
"angular2-template-loader": "0.6.2",
"awesome-typescript-loader": "3.1.2",
"browser-sync": "2.18.8",
"browser-sync-webpack-plugin": "1.1.4",
"codelyzer": "2.1.1",
"copy-webpack-plugin": "4.0.0",
"css-loader": "0.28.0",
"del": "2.2.2",
"event-stream": "3.3.4",
"exports-loader": "0.6.4",
"extract-text-webpack-plugin": "2.1.0",
"file-loader": "0.11.1",
"generator-jhipster": "<%= packagejs.version %>",
"html-loader": "0.4.5",
"html-webpack-plugin": "2.28.0",
"jasmine-core": "2.5.2",
<%_ if (protractorTests) { _%>
"jasmine-reporters": "2.2.1",
"jasmine-spec-reporter": "3.2.0",
"protractor": "5.1.1",
"protractor-jasmine2-screenshot-reporter": "0.3.5",
"ts-node": "2.1.0",
<%_ } _%>
"karma": "1.6.0",
"generator-jhipster": "<%= packagejs.version %>",
"karma": "1.4.1",
"karma-chrome-launcher": "2.0.0",
"karma-coverage": "1.1.1",
"karma-intl-shim": "1.0.3",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "0.2.0",
"karma-jasmine": "1.1.0",
"karma-intl-shim": "1.0.3",
"karma-jasmine-html-reporter": "0.2.2",
"karma-phantomjs-launcher": "1.0.4",
"karma-junit-reporter": "1.2.0",
"karma-notify-reporter": "1.0.1",
"karma-phantomjs-launcher": "1.0.4",
"karma-remap-istanbul": "0.6.0",
"karma-sourcemap-loader": "0.3.7",
"karma-webpack": "2.0.3",
"lazypipe": "1.0.1",
"lodash": "4.17.4",
"map-stream": "0.0.7",
"phantomjs-prebuilt": "2.1.14",
<%_ if (protractorTests) { _%>
"protractor": "5.1.1",
"protractor-jasmine2-screenshot-reporter": "0.3.5",
"ts-node": "2.1.0",
<%_ } _%>
"proxy-middleware": "0.15.0",
"rimraf": "2.6.1",
"run-sequence": "1.2.2",
"sourcemap-istanbul-instrumenter-loader": "0.2.0",
"string-replace-webpack-plugin": "0.1.3",
"style-loader": "0.16.1",
"to-string-loader": "1.1.5",
"tslint": "4.5.1",
"tslint-loader": "3.5.2",
"typescript": "2.2.2",
"webpack": "2.3.3",
"webpack-dev-server": "2.4.2",
"webpack-merge": "4.1.0",
"webpack-notifier": "1.5.0",
"webpack-visualizer-plugin": "0.1.11",
<%_ if (enableTranslation) { _%>
"merge-jsons-webpack-plugin": "1.0.5",
<%_ } _%>
"write-file-webpack-plugin": "3.4.2",
<%_ if (buildTool == 'maven') { _%>
"xml2js": "0.4.17",
<%_ } _%>
<%_ if (useSass) { _%>
"sass-loader": "5.0.1",
"node-sass": "4.5.0",
"postcss-loader": "1.3.0",
<%_ } _%>
<%_ otherModules.forEach(module => { _%>
"<%= module.name %>": "<%= module.version %>",
<%_ }); _%>
"yargs": "6.6.0"
"tslint": "4.5.1",
"phantomjs-prebuilt": "2.1.14",
"rimraf": "2.6.1",
"typescript": "2.2.2"
},
"engines": {
"node": ">=6.9.0"
},
"scripts": {
"lint": "tslint '<%= MAIN_SRC_DIR%>app/**/*.ts'",
"lint:fix": "tslint '<%= MAIN_SRC_DIR%>app/**/*.ts' --fix",
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --prod",
"test": "ng test --single-run",
"lint": "ng lint",
"lint:fix": "ng lint --fix",
"tsc": "tsc",
"tsc:w": "tsc -w",
"ngc": "ngc -p tsconfig-aot.json",
"cleanup": "rimraf <%= BUILD_DIR %>{aot,www}",
"start": "<%= clientPackageManager %> run webpack:dev",
"webpack:build": "<%= clientPackageManager %> run ngc && webpack --config webpack/webpack.vendor.js && webpack --config webpack/webpack.dev.js",
"webpack:build:dev": "webpack --config webpack/webpack.dev.js",
"webpack:build:vendor": "webpack --config webpack/webpack.vendor.js",
"webpack:dev": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --profile --port=9060",
"webpack:test": "<%= clientPackageManager %> run ngc && <%= clientPackageManager %> run test",
"webpack:prod": "<%= clientPackageManager %> run ngc && webpack -p --config webpack/webpack.vendor.js && webpack -p --config webpack/webpack.prod.js",
"test": "<%= clientPackageManager %> run lint && karma start src/test/javascript/karma.conf.js",
"test:watch": "karma start --watch",
<%_ if (protractorTests) { _%>
"e2e": "protractor <%= TEST_SRC_DIR %>protractor.conf.js",
"postinstall": "webdriver-manager update && node node_modules/phantomjs-prebuilt/install.js && <%= clientPackageManager %> run webpack:build"
"e2e": "ng e2e --proxy-conf proxy.conf.json",
"postinstall": "webdriver-manager update && node node_modules/phantomjs-prebuilt/install.js && yarn build"
<%_ } else { _%>
"postinstall": "node node_modules/phantomjs-prebuilt/install.js && <%= clientPackageManager %> run webpack:build"
"postinstall": "node node_modules/phantomjs-prebuilt/install.js && yarn build"
<%_ } _%>
}
}
5 changes: 2 additions & 3 deletions generators/client/templates/angular/_tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
]
},
"include": [
"src/main/webapp/app",
"src/test/javascript"
"src/main/webapp/app"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// load shim for IE
if (window.navigator.userAgent.indexOf('Trident/') > 0) {
var script = document.createElement('script');
script.src = 'core-js-shim.min.js';
script.src = 'shim.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
-%>
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { ProdConfig } from './blocks/config/prod.config';
import { enableProdMode } from '@angular/core';

import { <%=angular2AppName%>AppModule } from './app.module';

ProdConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,3 @@
-%>
/* after changing this file run '<%= clientPackageManager %> run webpack:build:vendor' or '<%= clientPackageManager %> install' or '<%= clientPackageManager %> run webpack:build' */
/* tslint:disable */
<%_ if (useSass) { _%>
import '../content/scss/vendor.scss';
<%_} else { _%>
import '../content/css/vendor.css';
<%_ } _%>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
limitations under the License.
-%>
import { enableProdMode } from '@angular/core';
import { DEBUG_INFO_ENABLED } from '../../app.constants';
import { environment } from '../../../environments/environment';

export function ProdConfig() {
// disable debug data on prod profile to improve performance
if (!DEBUG_INFO_ENABLED) {
enableProdMode();
if (environment.production) {
enableProdMode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { JhiLanguageService } from 'ng-jhipster';
import { ProfileService } from '../profiles/profile.service';
import { <% if (enableTranslation) { %>JhiLanguageHelper, <% } %>Principal, LoginModalService, LoginService } from '../../shared';

import { VERSION, DEBUG_INFO_ENABLED } from '../../app.constants';
import { environment } from '../../../environments/environment';

@Component({
selector: '<%=jhiPrefix%>-navbar',
Expand Down Expand Up @@ -57,7 +57,7 @@ export class NavbarComponent implements OnInit {
private profileService: ProfileService,
private router: Router
) {
this.version = VERSION ? 'v' + VERSION : '';
this.version = environment.VERSION;
this.isNavbarCollapsed = true;
<%_ if (enableTranslation) { _%>
this.languageService.addLocation('home');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const environment = {
production: true,
VERSION: 'v' + require('../../../../package.json').version
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
production: false,
VERSION: require('../../../../package.json').version
};