1.啟動,--content-base指明服務(wù)器的根目錄
webpack-dev-server --content-base ./dist
2.publicPath資源路徑,在請求文件時候需要加上路徑名
module.exports = {
entry: './src/js/index.js',
output: {
path: './dist/js',
filename: 'bundle.js',
publicPath: '/assets/'
}
}
3.webpack-dev-server 支持2種自動刷新的方式:
Iframe mode
inline mode
這2種模式配置的方式和訪問的路徑稍微有點(diǎn)區(qū)別,最主要的區(qū)別還是 Iframe mode 是在網(wǎng)頁中嵌入了一個 iframe ,將我們自己的應(yīng)用注入到這個 iframe 當(dāng)中去,因此每次你修改的文件后,都是這個 iframe 進(jìn)行了 reload 。

Paste_Image.png