2017-05-28 48 views
0

我想自動刪除評論與建設的WebPack建立時的時候。我想自動刪除評論與的WebPack

·我想刪除後//

·評論我可以刪除通過設置一些選項評論?

·我該怎麼辦?


▼main.js

// src/main.js I want to delete this part 
var m = require("mithril") 

var UserList = require("./views/UserList") 

m.mount(document.body, UserList) 
//I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part.I want to delete this part. 

▼的package.json

"scripts": { 
    "build": "webpack src/index.js bin/main.js -p" 
} 

$ npm start 
+0

你會想要在生產中使用縮小器,它會自動執行此操作。 – ceejayoz

回答

4

要定製的WebPack默認的配置了,你會我需要用你想要的選項創建一個特定的文件。

要剝離的意見,你將不得不通過comments: false在UglifyJs插件。

module.exports = { 
    // ... 

    plugins: [ 
    new webpack.optimize.UglifyJsPlugin({ 
     comments: false 
    }), 
    ] 
} 

然後,您可以寫配置webpack.prod.js,並與生產環境webpack --env=prod的WebPack運行。

瞭解詳情,請閱讀official documentation

+0

創建並放置webpack.prod.js後,它按預期工作。謝謝! – re1