nuxt.config.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. const pkg = require("./package");
  2. module.exports = {
  3. mode: "spa",
  4. env: {
  5. BASE_URL: process.env.BASE_URL,
  6. NODE_ENV: process.env.NODE_ENV
  7. },
  8. server: {
  9. host: "0.0.0.0",
  10. port: 3001
  11. },
  12. /**
  13. * 打包文件
  14. */
  15. build: {
  16. vendor: ["axios", "element-ui"]
  17. },
  18. /*
  19. ** Headers of the page
  20. */
  21. head: {
  22. title: "程序员客栈后台",
  23. meta: [
  24. { charset: "utf-8" },
  25. { name: "viewport", content: "width=device-width, initial-scale=1" },
  26. { hid: "description", name: "description", content: "程序员客栈后台" }
  27. ],
  28. link: [{ rel: "icon", type: "image/x-icon", href: "/favicon.ico" }]
  29. },
  30. /*
  31. ** Customize the progress-bar color
  32. */
  33. loading: { color: "#fff" },
  34. /*
  35. ** Global CSS
  36. */
  37. css: [
  38. "element-ui/lib/theme-chalk/index.css",
  39. "@/assets/css/common.css",
  40. "./styles/index.scss"
  41. ],
  42. /*
  43. ** Plugins to load before mounting the App
  44. */
  45. plugins: ["@/plugins/element-ui", "@/plugins/http", "@/plugins/quill"],
  46. /*
  47. ** Nuxt.js modules
  48. */
  49. modules: [
  50. // Doc: https://github.com/nuxt-community/axios-module#usage
  51. "@nuxtjs/axios",
  52. "@nuxtjs/proxy"
  53. ],
  54. /*
  55. ** Axios module configuration
  56. */
  57. axios: {
  58. // See https://github.com/nuxt-community/axios-module#options
  59. },
  60. /**
  61. * Proxy
  62. */
  63. proxy: [
  64. ["/api", { target: "http://local.proginn.com/", changeOrigin: true }]
  65. ],
  66. /*
  67. ** Build configuration
  68. */
  69. build: {
  70. /*
  71. ** You can extend webpack config here
  72. */
  73. extractCSS: { allChunks: true }, // css 独立打包 link 的形式加载
  74. splitChunks: {
  75. chunks: "all",
  76. automaticNameDelimiter: "."
  77. },
  78. optimization: {
  79. splitChunks: {
  80. cacheGroups: {
  81. commons: {
  82. name: "commons",
  83. chunks: "all",
  84. minChunks: 2,
  85. priority: 0,
  86. minSize: 1
  87. },
  88. vendor: {
  89. name: "vendor",
  90. test: /[\\/]node_modules[\\/]/,
  91. chunks: "all",
  92. priority: 10
  93. }
  94. }
  95. },
  96. },
  97. publicPath:process.env.NODE_ENV=="dev"?"_nuxtboss":"_nuxt",
  98. extend(config, ctx) { }
  99. },
  100. router: {
  101. middleware: "initialize"
  102. }
  103. };