如何提供webpack文件?

时间:2018-02-06 10:43:06

标签: webpack webpack-dev-server

我通过使用dllreferenceplugin创建了vendor.js和mainbundle.js。这是我正在运行的命令:

 "npm run build:dll && webpack --config=webpack.dev.config.js --watch --progress"

在控制台中我可以看到:

Hash: bad1c37262433a8e91d4                                                                                                             
Version: webpack 3.10.0                                                                                                                
Time: 14767ms                                                                                                                          
        Asset    Size  Chunks             Chunk Names                                                                                  
dll.vendor.js  244 kB       0  [emitted]  vendor                                                                                       
   [0] dll vendor 12 bytes {0} [built]                                                                                                 
   [1] ./vendors.js 89 bytes {0} [built]                                                                                               
   [5] (webpack)/buildin/global.js 509 bytes {0} [built]                                                                               
   [6] (webpack)/buildin/module.js 517 bytes {0} [built]                                                                               
    + 5 hidden modules                                                                                                                 
  0% compiling                                                                                                                         
Webpack is watching the files…                                                                                                         

Hash: 83dc1ce27d7783871347                                                                                                             
Version: webpack 3.10.0                                                                                                                
Time: 5226ms                                                                                                                           
     Asset     Size  Chunks             Chunk Names                                                                                    
mainapp.js  3.66 kB       0  [emitted]  app                                                                                            
   [0] ./client/app/app.js 357 bytes {0} [built]                                                                                       
   [1] delegated ../node_modules/angular/index.js from dll-reference vendor 42 bytes {0} [built]                                       
    + 1 hidden module 

如何配置webpack-dev-server来提供这些文件?

1 个答案:

答案 0 :(得分:0)

向您添加devServer部分webpack.config.js

https://webpack.js.org/configuration/dev-server/#devserver

在此部分中,contentBase属性指定了您希望从中提供应用程序的位置。

然后,当您完成此操作后,您应该能够运行webpack-dev-server并使用您的webpack捆绑资产为您的应用程序提供服务。