下面是项目中用到的一段代码
// webpack version 2.2.1
entry: [
// must be first entry to properly set public path
'./src/webpack-public-path',
'webpack-hot-middleware/client?reload=true',
path.resolve(__dirname, 'src/index.js') // Defining path seems necessary for this to work consistently on Windows machines.
],
output: {
path: path.resolve(__dirname, 'dist'), // Note: Physical files are only output by the production build task `npm run build`.
publicPath: '/',
filename: 'bundle.js'
},
请问webpack-public-path
代表的是什么意思?
我的理解是在entry中设置output的publicpath,如果这样的话webpack-public-path
在项目中又代表什么呢?
webpack有一个全局变量
__webpack_public_path__
,这个webpack-public-path
中的代码应该就是在设置这个变量。至于
webpack-public-path
是什么意思,项目的src目录下肯定有个webpack-public-path.js