Other
When projects are completed, you can build your application only run one command:
# build for production environmentnpm run build:prod# build for stage environmentnpm run build:stageAfter the build package is successful, thedist folder will be generated in the root directory, which is to build a packaged file, usually static files such as***.js,***.css,index.html, etc. .
If you need a custom build, such as specifying the dist directory, you need to configure it throughoutputDir inconfig.
The configuration of all test environments or formal environment variables is in the.env.xxxx file such as.env.development.
They all inject into the global context via thewebpack.DefinePlugin plug-ins.
note! ! !
Environment variables must start withVUE_APP_. Such as:VUE_APP_API,VUE_APP_TITLE
You can access them in your application code:
console.log(process.env.VUE_APP_xxxx)If your build file is large, you can optimize your code by building and analyzing the size distribution of dependent modules using thewebpack-bundle-analyzer.
npm run preview ----reportAfter running you can see the specific size distribution athttp://localhost:9526/report.html

TIP
It is recommended to use gzip, after using the volume will be only the original 1/3 or so. You can also use lazy loading or Code Splitting.
For publishing, you only have to publish the resulting static file after build, which is usually the static file in thedist folder, to your cdn or static server. Note that theindex.html usually will be an entry page for your backend service. You may need to change the page's import path after determining static for JS and css.
TIP
In deployment may find that the resource path is wrong, just modify the@/config/index.js file resource path.
// changes configure depending on your own pathpublicPath:'./'In vue-element-admin, the front-end routing usesvue-router, so you have two options:browserHistory andhashHistory.
Simply speaking, the difference between them is the deal with routing.hashHistory is processed by the path following#, front-end routing management throughHTML 5 History, andbrowserHistory is similar to our usual page access path, and with not#, but must through the server's configuration.
This project useshashHistory by default, so if you have#in your url and you want to get rid of it, you need to switch tobrowserHistory.
Modifysrc/router/index.js mode。
exportdefaultnewRouter({// mode: 'history' // Need backend support})TIP
Detail seevue-router document