[英]How does angular-cli@webpack work?
I have used angular-cli with systemJS and am now comfortable with its build process,test cases & component interaction. 我在systemJS中使用了angular-cli,现在对它的构建过程,测试用例和组件交互感到满意。
recently I upgraded my angular-cli
to angular-cli@webpack
. 最近,我将我的angular-cli
升级到angular-cli@webpack
。
But I am pretty confused with following things: 但是我对以下事情感到很困惑:
lodash,ng2-bootstrap
etc with this webpack configuration as I cant see any webpack.config.ts
file. 如何使用此webpack配置安装lodash,ng2-bootstrap
等第三方库lodash,ng2-bootstrap
因为我看不到任何webpack.config.ts
文件。 Thanks in advance. 提前致谢。
ng build
it will build everything and output the files to the Dist folder 当您运行ng build
,它将构建所有内容并将文件输出到Dist文件夹 npm install 'external-dependency'
and you're good to go, just import it in the files u need it (and in app.module.ts) 只需运行npm install 'external-dependency'
,就可以了,只需将其导入您需要的文件(以及app.module.ts中) ng build
first, see 1 您需要先运行ng build
,请参见1 webpack read entry and build to desired output. webpack读取条目并生成所需的输出。 here is an example 这是一个例子
entry: { 'app': './main.ts'//your entry point }, output: { path: helpers.root('dist'), filename: 'bundle.js' //your build file }
It's simple, install your dependencies through npm and require them in your project and webpack will take care of them means it will bundle them into your build. 很简单,通过npm安装依赖项,并在项目中要求它们,而webpack会照顾它们,这意味着将它们捆绑到您的构建中。
npm install lodash
and in your project 在你的项目中
require("lodash")
ng-serve
it will not show you physicals files but if you run ng-build it will build physicals files to dist folder and you will be able to see them. 只要您使用ng-serve
运行您的应用程序,它就不会显示物理文件,但是如果您运行ng-build,它将把物理文件构建到dist文件夹,您将能够看到它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.