My angular 4 UI for a java web application depends only on the below few bundles. I ran the below commands from webapps root. App works fine. I want to know the best practices as I'm new to angular.
我对java Web应用程序的角度4 UI仅取决于以下几个捆绑包。我从webapps root运行以下命令。应用程序正常。我想知道最好的做法,因为我是棱角分明的新手。
npm install rxjs
npm install @angular/core@4.4.6 @angular/common@4.4.6 @angular/compiler@4.4.6 @angular/platform-browser@4.4.6 @angular/platform-browser-dynamic@4.4.6 @angular/router@4.4.6 @angular/forms@4.4.6 --save
npm install typescript@2.4.2 --save
npm install plugin-typescript@5.2.7 --save
I'm referring the installed bundles from systemjs.config.js
like below:
我是指systemjs.config.js中安装的bundle,如下所示:
paths: {
'npm:' : 'node_modules/'
},
map: {
'@angular/core' : 'npm:@angular/core/bundles/core.umd.js'
.
.
}
Queries:
查询:
- The app should not be heavy, could not include the entire
node_modules
inwar
- 应用程序不应该很重,不能包含战争中的整个node_modules
- If I keep
node_modules
in project root instead of webapps, how do I refer it fromsystemjs.config.js
- 如果我将node_modules保留在项目根目录而不是webapps中,我该如何从systemjs.config.js中引用它
- I just want those bundles and not the huge file stack that gets downloaded while running
npm install @angular/cli
- 我只想要那些捆绑而不是在运行npm install @ angular / cli时下载的巨大文件堆栈
- If we can use global
node_modules
, how to refer to that fromsystemjs.config.js
(I prefer keeping it within project not to disturb other applications in the server using different versions) - 如果我们可以使用全局node_modules,如何从systemjs.config.js引用它(我更喜欢将它保留在项目中,不要使用不同的版本来干扰服务器中的其他应用程序)
- Finally, what should I include in
build.gradle
to download the required bundles while gradle builds - 最后,我应该在build.gradle中包含什么来在gradle构建时下载所需的bundle
1 个解决方案
#1
1
As @Oliver Charlesworth said, Gradle has his limitations, but you can create a custom gradle task.
正如@Oliver Charlesworth所说,Gradle有其局限性,但您可以创建自定义gradle任务。
Example:
例:
task npmInstall(type: Exec) {
workingDir 'src/main/webapp'
commandLine 'npm', 'install'
}
Add the build dependency to your war
build step
将构建依赖项添加到war构建步骤
war {
dependsOn npmBuild
}
#1
1
As @Oliver Charlesworth said, Gradle has his limitations, but you can create a custom gradle task.
正如@Oliver Charlesworth所说,Gradle有其局限性,但您可以创建自定义gradle任务。
Example:
例:
task npmInstall(type: Exec) {
workingDir 'src/main/webapp'
commandLine 'npm', 'install'
}
Add the build dependency to your war
build step
将构建依赖项添加到war构建步骤
war {
dependsOn npmBuild
}