你完成了工程開發,需要部署到外網環境,要進行下面的步驟:
一、首先你要購買一個服務器或者有自己的服務器。我介紹給大家的一個免費的服務器:http://free.3v.do/index.html可以免費內存空間100M;
二、修改項目config文件夾->index.js文件夾->assetsPublicPath(在build里邊)@“/”改為@“./”,如:
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
productionSourceMap: true,
// 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-plugin
productionGzip: 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 off
bundleAnalyzerReport: process.env.npm_config_report
},
然后:npm run build下生成一個dist文件夾,直接點開dist問價夾下的index.html就是你的項目,其他的static是你的資源文件;
這時候能打開就沒問題,現在就是把dist目錄下的所有文件(記住是dist文件下的)。
三、尋找上傳工具:我用的都是免費的Yummy FTP;
綁定賬號:
上傳你的代碼:
現在就打開你的域名:http://anneandpeter.3vcm.net/#/
就有你自己的項目網頁了:(我用的是內網的ip,所以數據你們看不到,數據沒有發布到外網)