vue.config.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const path = require('path')
  2. const resolve = dir => {
  3. return path.join(__dirname, dir)
  4. }
  5. // 项目部署基础
  6. // 默认情况下,我们假设你的应用将被部署在域的根目录下,
  7. // 例如:https://www.my-app.com/
  8. // 默认:'/'
  9. // 如果您的应用程序部署在子路径中,则需要在这指定子路径
  10. // 例如:https://www.foobar.com/my-app/
  11. // 需要将它改为'/my-app/'
  12. const BASE_URL = process.env.NODE_ENV === 'production'
  13. ? '/dashboard/'
  14. : '/dashboard'
  15. // : '/dashboard'
  16. const luOutPath = '../'
  17. module.exports = {
  18. css: {
  19. loaderOptions: { // 向 CSS 相关的 loader 传递选项
  20. less: {
  21. javascriptEnabled: true
  22. }
  23. }
  24. },
  25. publicPath: BASE_URL,
  26. // tweak internal webpack configuration.
  27. // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
  28. // 如果你不需要使用eslint,把lintOnSave设为false即可
  29. lintOnSave: false,
  30. // webpack 打包导出路径
  31. outputDir: luOutPath + 'public/dashboard',
  32. indexPath: luOutPath + 'dashboard/index.html',
  33. chainWebpack: config => {
  34. config.resolve.alias
  35. .set('@', resolve('src')) // key,value自行定义,比如.set('@@', resolve('src/components'))
  36. .set('_c', resolve('src/components'))
  37. },
  38. // 设为false打包时不生成.map文件
  39. productionSourceMap: false,
  40. // 这里写你调用接口的基础路径,来解决跨域,如果设置了代理,那你本地开发环境的axios的baseUrl要写为 '' ,即空字符串
  41. /*devServer: {
  42. port: 80,
  43. proxy: {
  44. '/api': {
  45. target: 'http://127.0.0.42/',
  46. changeOrigin: true
  47. }
  48. }
  49. }*/
  50. }