Vue-cli: Add build option to set publicPath

Created on 13 Mar 2018  路  5Comments  路  Source: vuejs/vue-cli

What problem does this feature solve?

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

What does the proposed API look like?

vue-cli-service build --publicPath='/repo-name'

Most helpful comment

Use baseUrl option in vue.config.js.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings