2016-10-24 19 views
1

asp.net內核的文檔顯示如何使用grunt或gulp執行bundling and minificationcssjs文件。 但是,當我使用vs 2015創建項目時,它會將bundleconfig.json文件添加到項目中。我想縮小wwwroot/js文件夾內的所有js文件。所以我更新內部bundleconfig.json現有生產線使用通配符*如何縮小asp.net核心中的文件?

{ 
    "outputFileName": "wwwroot/js/*.min.js", 
    "inputFiles": [ 
     "wwwroot/js/*.js" 
    ], 
    // Optionally specify minification options 
    "minify": { 
     "enabled": true, 
     "renameLocals": true 
    }, 
    // Optinally generate .map file 
    "sourceMap": false 
    } 

然而,當我發佈的項目中,我得到錯誤

處理的wwwroot/JS/*。min.js非法字符路徑。參數 名稱:路徑

回答

0

我認爲你不能在outputFileName通配符,所以這裏使用絕對路徑。要創建多個捆綁包,請在陣列中創建多個條目。

[ 
    { 
    "outputFileName": "wwwroot/css/site.min.css", 
    // An array of relative input file paths. Globbing patterns supported 
    "inputFiles": [ 
     "wwwroot/css/site.css" 
    ] 
    }, 
    { 
    "outputFileName": "wwwroot/js/site.min.js", 
    "inputFiles": [ 
     "wwwroot/js/site.js" 
    ], 
    // Optionally specify minification options 
    "minify": { 
     "enabled": true, 
     "renameLocals": true 
    }, 
    // Optinally generate .map file 
    "sourceMap": false 
    } 
] 

上面這一個是從默認bundleconfig.json

在一個側面說明:

*.min.js也是*.js BTW。所以,如果你不刪除前一個,它將被遞歸地添加到每個捆綁中,所以要小心。