我正在使用angular-cli
开发一个角度2应用程序angular 2 - 2.1.1
angular-cli - 1.0.0-beta.18
该应用程序的一个功能是列出所有事件并点击一个事件在3个选项卡中显示事件详细信息 - 概述,照片&车票
我开发这个的方式是我存储在我的数据库中的所有事件以及概述,照片和票证选项卡的内容都在数据库中。所以这样我只需要一个组件可以呈现3个选项卡并填充从DB中获取的每个选项卡内容。现在有趣的是,大多数事件将具有相同的布局和部分,但对于某些事件,可能需要不同的布局。因此,为了解决这个问题,我正在做的是与2个选项卡内容(概述,照片,票证)中的每一个一起,我还存储将呈现此事件的组件的名称。
使用ComponentFactoryResolver
和ViewContainerRef
的组件somehow managed to get the component from the name并且一切正常,但是当我尝试为angular-cli
踢树的生产环境进行构建时出现问题-shaking以及我在代码中实际未引用/导入但基于从db检索的数据动态创建/呈现的所有组件都被删除,我的应用程序崩溃,因为它无法找到这些组件。
所以我的问题是/是
答案 0 :(得分:0)
将这些组件添加到
Abdul Ovais@DESKTOP-31UBAGF /xampp/htdocs/angular-client
$ npm start
> EES@1.0.0 start D:\xampp\htdocs\angular-client
> npm run server:dev
> EES@1.0.0 server:dev D:\xampp\htdocs\angular-client
> webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "server:dev"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! EES@1.0.0 server:dev: `webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the EES@1.0.0 server:dev script 'webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the EES package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs EES
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls EES
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\xampp\htdocs\angular-client\npm-debug.log
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! EES@1.0.0 start: `npm run server:dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the EES@1.0.0 start script 'npm run server:dev'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the EES package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run server:dev
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs EES
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls EES
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\xampp\htdocs\angular-client\npm-debug.log
https://angular.io/docs/ts/latest/api/core/index/NgModule-interface.html#!#entryComponents-anchor