1.生產環境壓縮混淆代碼
yarn add uglifyjs-webpack-plugin
webpack.prod.conf.js
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: false,
sourceMap: false,
})
]
},
2.生產環境發佈
使用nginx作爲Web服務器,nginx配置:
server {
listen 7766;
root F:\website\dist;
index index.html;
location / {
try_files $uri $uri/ @fallback;
index index.html;
}
location @fallback {
rewrite ^.*$ /index.html break;
}
}
具體可以參考這位大哥的寫法
項目github地址:https://github.com/kakaoG/react-webpack