我的应用程序构建正常。但是当我通过输入
来构建生产时 ng build --prod
在我的控制台中,我收到以下巨大警告和奇怪的dist
输出:
WARNING in main.ff67c2edc2d42d6adb60.bundle.js from UglifyJs
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:235,5]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:5310,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:5310,4]
Side effects in initialization of unused variable TypeModifier [main.ff67c2edc2d42d6adb60.bundle.js:5476,4]
Side effects in initialization of unused variable BuiltinMethod [main.ff67c2edc2d42d6adb60.bundle.js:5732,4]
Side effects in initialization of unused variable StmtModifier [main.ff67c2edc2d42d6adb60.bundle.js:5966,4]
Side effects in initialization of unused variable freeExports [main.ff67c2edc2d42d6adb60.bundle.js:8176,4]
Side effects in initialization of unused variable freeModule [main.ff67c2edc2d42d6adb60.bundle.js:8177,4]
Side effects in initialization of unused variable ProviderAstType [main.ff67c2edc2d42d6adb60.bundle.js:9022,4]
Side effects in initialization of unused variable PropertyBindingType [main.ff67c2edc2d42d6adb60.bundle.js:9063,4]
Side effects in initialization of unused variable RequestMethod [main.ff67c2edc2d42d6adb60.bundle.js:9394,4]
Side effects in initialization of unused variable ReadyState [main.ff67c2edc2d42d6adb60.bundle.js:9409,4]
Side effects in initialization of unused variable ResponseType [main.ff67c2edc2d42d6adb60.bundle.js:9422,4]
Side effects in initialization of unused variable ContentType [main.ff67c2edc2d42d6adb60.bundle.js:9436,4]
Side effects in initialization of unused variable ResponseContentType [main.ff67c2edc2d42d6adb60.bundle.js:9447,4]
Side effects in initialization of unused variable TagContentType [main.ff67c2edc2d42d6adb60.bundle.js:11792,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:12589,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:12589,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:15093,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:15093,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:15143,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:15143,4]
Side effects in initialization of unused variable ViewType [main.ff67c2edc2d42d6adb60.bundle.js:19907,4]
Side effects in initialization of unused variable HTMLCollection [main.ff67c2edc2d42d6adb60.bundle.js:21081,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:23278,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:23278,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:23323,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:23323,4]
Side effects in initialization of unused variable HTMLCollection [main.ff67c2edc2d42d6adb60.bundle.js:25631,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:27538,8]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:27538,8]
Dropping unused variable SAFE_SRCSET_PATTERN [main.ff67c2edc2d42d6adb60.bundle.js:33759,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:34293,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:34293,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:34392,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:34392,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:34498,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:34498,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:34603,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:34603,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35538,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35616,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35679,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35786,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35851,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:35990,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36101,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36237,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36331,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36454,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36577,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36690,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36836,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:36921,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:36945,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:36954,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:36963,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:36972,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:36981,16]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37097,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37164,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37248,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37315,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37397,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37477,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37580,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37681,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37752,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37819,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37890,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:37960,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38033,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38107,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38192,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38278,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38361,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38431,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38541,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38652,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38716,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38780,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38848,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38916,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:38993,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39073,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39156,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39257,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39385,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39534,4]
Dropping unused variable suffix [main.ff67c2edc2d42d6adb60.bundle.js:39543,12]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39647,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39747,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39833,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:39965,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40038,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40119,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40205,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40298,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40389,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40455,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40523,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40615,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40755,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40829,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:40951,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41051,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41166,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41260,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41346,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41509,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41595,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41681,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41779,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41845,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:41972,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42049,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42113,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42241,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42350,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42415,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42485,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42565,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42750,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42815,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:42891,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:42915,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:42924,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:42933,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:42942,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:42951,16]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43044,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43212,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43284,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43398,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43512,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43605,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43678,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43741,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43874,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:43967,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44038,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44104,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44229,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44322,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44417,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44479,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44542,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44691,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44753,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44836,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:44909,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:45040,4]
Side effects in initialization of unused variable matches [main.ff67c2edc2d42d6adb60.bundle.js:47583,12]
Dropping unused variable __unused [main.ff67c2edc2d42d6adb60.bundle.js:47891,4]
Non-strict equality against boolean: != true [main.ff67c2edc2d42d6adb60.bundle.js:49247,15]
Side effects in initialization of unused variable transitiveModuleMeta [main.ff67c2edc2d42d6adb60.bundle.js:50293,16]
Dropping unused variable EVENT [main.ff67c2edc2d42d6adb60.bundle.js:50654,4]
Side effects in initialization of unused variable SecurityContext [main.ff67c2edc2d42d6adb60.bundle.js:58783,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:61560,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:61560,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:61730,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:61730,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:61842,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:61842,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62014,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62014,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62075,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62075,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62180,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62180,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62667,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62667,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62726,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62726,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62933,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62933,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:62989,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:62989,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63114,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63114,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63236,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63236,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63351,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63351,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63391,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63391,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63515,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63515,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63805,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63805,4]
Non-strict equality against boolean: == true [main.ff67c2edc2d42d6adb60.bundle.js:63892,16]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:63936,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:63936,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64000,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64000,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64149,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64149,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64322,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64322,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64362,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64362,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64421,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64421,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64513,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64513,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64558,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64558,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:64839,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:64839,4]
Non-strict equality against boolean: != false [main.ff67c2edc2d42d6adb60.bundle.js:67116,47]
Dropping unused function _fetchSylesFromState [main.ff67c2edc2d42d6adb60.bundle.js:71181,9]
Side effects in initialization of unused variable strCases [main.ff67c2edc2d42d6adb60.bundle.js:72884,12]
Dropping unused variable renderMethod [main.ff67c2edc2d42d6adb60.bundle.js:75587,12]
Dropping unused variable __unused [main.ff67c2edc2d42d6adb60.bundle.js:76550,4]
Dropping unused function normalizeArray [main.ff67c2edc2d42d6adb60.bundle.js:79198,9]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:81819,12]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:81819,12]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:81843,8]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:81843,8]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:82393,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:82393,4]
Side effects in initialization of unused variable pathLocationStrategy [main.ff67c2edc2d42d6adb60.bundle.js:82878,4]
Side effects in initialization of unused variable hashLocationStrategy [main.ff67c2edc2d42d6adb60.bundle.js:82882,4]
Dropping side-effect-free statement [main.ff67c2edc2d42d6adb60.bundle.js:83003,0]
Side effects in initialization of unused variable __WEBPACK_IMPORTED_MODULE_5__src_dnd_component__ [main.ff67c2edc2d42d6adb60.bundle.js:82991,25]
Dropping unused variable appRoutingProviders [main.ff67c2edc2d42d6adb60.bundle.js:83328,4]
Side effects in initialization of unused variable __WEBPACK_IMPORTED_MODULE_0__environments_environment__ [main.ff67c2edc2d42d6adb60.bundle.js:83371,25]
Side effects in initialization of unused variable __WEBPACK_IMPORTED_MODULE_1__app_component__ [main.ff67c2edc2d42d6adb60.bundle.js:83372,25]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:93857,4]
Declarations in unreachable code! [main.ff67c2edc2d42d6adb60.bundle.js:93857,4]
Condition always true [main.ff67c2edc2d42d6adb60.bundle.js:96729,4]
Dropping unreachable code [main.ff67c2edc2d42d6adb60.bundle.js:96733,7]
WARNING in polyfills.c27b87b9e504b84ce8dc.bundle.js from UglifyJs
Condition left of || always false [polyfills.c27b87b9e504b84ce8dc.bundle.js:3722,63]
Condition left of || always false [polyfills.c27b87b9e504b84ce8dc.bundle.js:3723,62]
Dropping side-effect-free statement [polyfills.c27b87b9e504b84ce8dc.bundle.js:3751,21]
Side effects in initialization of unused variable Zone [polyfills.c27b87b9e504b84ce8dc.bundle.js:3274,5]
怎么了?
答案 0 :(得分:0)
警告告诉你确切的错误,你的代码中某处的if语句总是会被评估为true,可能导致其他代码永远不会被执行。
这可能是预期和期望的行为,但是您的代码应该以不同的方式编写。重构if语句,警告将消失。
此警告只是一个警告,您生成的dist文件夹已正确生成,因此没有任何损失。
答案 1 :(得分:0)
就像stijn26所说:我们故意在angular-cli中配置webpack来发出这些警告。它们代表了代码中发生的优化和死代码消除。
我们没有办法压制警告,但我个人认为,我希望看到这些结果可以准确了解我的代码在未来的优化位置。