2016-08-18 31 views
0

我一直在努力縮小我的生產代碼(當我在開發模式下運行webpack時,一切工作正常)。主要區別在於UglifyJsPlugin插件。當我爲我的項目,該插件我得到這個在JS控制檯:使用UglifyJsPlugin驗證@Input修飾器

polyfills.b0a99d4.bundle.js:5 Unhandled Promise rejection: Template parse errors: 
Can't bind to 'articles' since it isn't a known property of 'feed-grid'. 
1. If 'feed-grid' is an Angular component and it has 'articles' input, then verify that it is part of this module. 
2. If 'feed-grid' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. 

不過,我相信我是正確的說出我的輸入(特別是因爲它的工作原理沒有這個插件)。

import { Component, Input } from '@angular/core'; 
import { ArticleModel } from '../../models/article.model'; 

@Component({ 
    selector: 'feed-grid', 
    styleUrls: ['./feed-grid.scss'], 
    template: require('./feed-grid.html') 
}) 

export class FeedGrid { 
    @Input() articles: ArticleModel[] = []; 

    constructor() {} 
} 

我錯過了這個Uglify插件的東西,也許爲它聲明輸入?我可以找到談論@Input()或輸入組件屬性驗證的任何地方。如果這有幫助,我正在使用rc5。

感謝, 喬恩

回答

1

模板解析是不是因爲它應該和角度團隊提供了一個解決辦法對他們的文檔的權利,但現在完全希望它應該儘快修復webpack.config文件中添加此工作正常

htmlLoader: { 
    minimize: false // workaround for ng2 
    }, 

或者

{ 
    test: /\.html$/, 
    loader: `html?-minimize` 
} 

嘗試,這也

使用mangle:false來顯式禁用mangling。

new webpack.optimize.UglifyJsPlugin({  
      // Mangling specific options 
      mangle: false 
     }) 

Source

workaround from angular.io

+0

我沒有使用htmlLoader的,但UglifyJS。你可以添加它到你的答案(設置mangle:false)插件設置https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin –

+0

更新謝謝。 –