npm run build后如何打开index.html跑起项目
生活随笔
收集整理的這篇文章主要介紹了
npm run build后如何打开index.html跑起项目
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Tip: built files are meant to be served over an HTTP server.? ?Opening index.html over file:// won't work.
提示:構建的文件應該通過HTTP服務器提供服務。在文件:/上打開index.html不起作用。
?
其實直接本地就可以打開。。。
只需要在build配置文件修改:
assetsPublicPath: './', build: {// Template for index.htmlindex: path.resolve(__dirname, '../dist/index.html'),// PathsassetsRoot: path.resolve(__dirname, '../dist'),assetsSubDirectory: 'static',assetsPublicPath: './',/*** Source Maps*/productionSourceMap: true,// https://webpack.js.org/configuration/devtool/#productiondevtool: '#source-map',// Gzip off by default as many popular static hosts such as// Surge or Netlify already gzip all static assets for you.// Before setting to `true`, make sure to:// npm install --save-dev compression-webpack-pluginproductionGzip: false,productionGzipExtensions: ['js', 'css'],// Run the build command with an extra argument to// View the bundle analyzer report after build finishes:// `npm run build --report`// Set to `true` or `false` to always turn it on or offbundleAnalyzerReport: process.env.npm_config_report}?
轉載于:https://www.cnblogs.com/ivan5277/p/10829253.html
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的npm run build后如何打开index.html跑起项目的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开源视觉salm算法介绍
- 下一篇: 大数据技术原理与应用:期末考点总结