Skip to content

Instantly share code, notes, and snippets.

@fyunli
Created October 16, 2018 11:32
Show Gist options
  • Select an option

  • Save fyunli/7ee3f169864216829ae05864cec15670 to your computer and use it in GitHub Desktop.

Select an option

Save fyunli/7ee3f169864216829ae05864cec15670 to your computer and use it in GitHub Desktop.
修改vue.config.js中的baseUrl为'./'
module.exports = {
baseUrl: './'
};
然后执行npm run build
What is expected?
所有URL都应以“./”开头,成为相对路径,以便适配混合app开发。
建议一:
将node_modules@vue\cli-service\lib\config\css.js中的css/[name].[contenthash:8].css
修改为./css/[name].[contenthash:8].css,
建议二:
将node_modules@vue\cli-service\lib\config\prod.js中的js/[name]${isLegacyBundle ?-legacy: ``}.[chunkhash:8].js
修改为./js/[name]${isLegacyBundle ?-legacy: ``}.[chunkhash:8].js
What is actually happening?
在混合APP开发中所有的路径都应以相对路径,或者给别人做案例时也应该以相对路径URL开头,以达到只要浏览器访问index.html就能看到内容。如果仅仅修改baseUrl为"./"或"",那么所有的编译的js和css都会生成在根目录下,很混乱。为了保证文件的可视阅读性,除index.html的文件都应该归类存储。
建议一:
将node_modules@vue\cli-service\lib\config\css.js中的css/[name].[contenthash:8].css
修改为./css/[name].[contenthash:8].css,
建议二:
将node_modules@vue\cli-service\lib\config\prod.js中的js/[name]${isLegacyBundle ?-legacy: ``}.[chunkhash:8].js
修改为./js/[name]${isLegacyBundle ?-legacy: ``}.[chunkhash:8].js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment