我使用webpack给项目打包成带hash后缀的文件,但是在nginx中我不知道该怎么配置index.html文件。
webpack打包后文件如下:
nginx中location配置如下:
location ^~ /assets {
root /home/devops-web/dist;
}
location ^~ /bundle {
root /home/devops-web/dist;
}
location / {
rewrite .* /index.html break;
root /home/devops-web/dist;
index index.html index.htm;
}
这个index.html的配置应该是不对的,请问应该怎么配置啊?
你的index里有什么会经常需要变化的东西么?
如果没有话,可以不要配置后缀,直接缓存着就行了。
如果有的话,建议抽出来作为组件,保证index.html的干净和纯粹,这样也避免了你ngix配置的困惑。