I'm trying to deploy a Vue.js application to Github Pages. Github Pages deploys to a URL that looks like username.github.io/repo-name. The problem is that the vue-cli-service build
command builds links that look like /js/vendor.2e8c48c3.js
rather than repo-name/js/vendor.2e8c48c3.js
or ./js/vendor.2e8c48c3.js
.
There is a webpack option, publicPath
, that I'm pretty sure is the solution, but there isn't a way to set that option with vue-cli.
https://webpack.js.org/api/cli/#output-options
https://github.com/webpack/docs/wiki/configuration#outputpublicpath
vue-cli-service build --publicPath='/repo-name'
Use baseUrl option in vue.config.js.
- configuration has an unknown property 'baseUrl'. These properties are valid:
vue-app | object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?, filename?, publicPath?, port?, socket?, watchOptions?, headers?, logLevel?, clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?, pfxPassphrase?, requestCert?, inline?, disableHostCheck?, public?, https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?, features?, compress?, proxy?, historyApiFallback?, staticOptions?, setup?, before?, after?, stats?, reporter?, logTime?,noInfo?, quiet?, serverSideRender?, index?, log?, warn? }
baseUrl is not valid?
@johansaldes baseUrl
is a top level property, not a devServer
option.
How can we change the file name under dist folder when we build the project with vue-cli-service build
@yyx990803 add a devServer option to change the baseUrl or publicPath is a good idea, this function is needed for our automatic construction.
Most helpful comment
Use baseUrl option in vue.config.js.