我不太确定publicPath
中的webpack
是做什么的。具体来说,output.publicPath
。在github文档中,我看到了这个
https://github.com/webpack/docs/wiki/configuration#outputpublicpath
Javascript / HTML页面视图中的output.path。
对于reactjs
热装,我有
output: {
path: path.resolve('./public/bundle/'),
// path: './public/bundle',
filename: 'main.js',
// Webpack dev server is bound to port 8080, we have to force use of absolute URL, using the publicPath property
publicPath: 'http://localhost:8080/public/bundle/'
},
这是否意味着构建的网络包文件(main.js
)已放置在我的dev-server
http://localhost:8080/public/bundle/中?
答案 0 :(得分:1)
Yep, Webpack needs to know where you'll host the generated bundle file (or any other assets it generates) so that it can request additional chunks or files that are loaded from file-loader or url-loader. Hence in this case, when you start your webpack-dev-server, you'll be able to access your bundle file at: http://localhost:8080/public/bundle/main.js
(any related assets like images, commonchunk, fonts, etc will be under that path)
Outside of dev-server, you can use it to define the location of your assets (from a custom directory or even a CDN)