nuxt.config.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. const HtmlWebpackPlugin = require('html-webpack-plugin');
  2. const path = require('path')
  3. const isProdMode = Object.is(process.env.NODE_ENV, 'production')
  4. const baseUrl = process.env.BASE_URL || (isProdMode ? 'https://sso.ubtob.com/' : 'https://test-sso-server.uuzcc.cn/')
  5. module.exports = {
  6. router: {
  7. middleware: 'check-auth'
  8. },
  9. transition: {
  10. name: 'fade',
  11. mode: 'out-in'
  12. },
  13. /*
  14. ** Headers of the page
  15. */
  16. head: {
  17. title: '账户中心',
  18. meta: [{
  19. charset: 'utf-8'
  20. },
  21. {
  22. 'http-equiv': 'X-UA-Compatible',
  23. content: 'IE=edge,chrome=1'
  24. },
  25. {
  26. name: 'render',
  27. content: 'webkit'
  28. },
  29. {
  30. name: 'viewport',
  31. content: 'width=device-width, initial-scale=1'
  32. },
  33. {
  34. hid: 'description',
  35. name: 'description',
  36. content: '账户中心'
  37. }
  38. ],
  39. link: [{
  40. rel: 'icon',
  41. type: 'image/x-icon',
  42. href: '/U.png'
  43. }]
  44. },
  45. /*
  46. ** Customize the progress-bar color
  47. */
  48. loading: '~components/common/nuxt-loading/Loading.vue',
  49. /*
  50. ** Build configuration
  51. */
  52. build: {
  53. /*
  54. ** Run ESLINT on save
  55. */
  56. extractCSS: {
  57. allChunks: true
  58. },
  59. extend(config, {
  60. dev,
  61. isClient,
  62. isServer
  63. }) {
  64. Object.assign(config.resolve.alias, {
  65. '~utils': path.resolve(__dirname, 'utils'),
  66. '~components': path.join(__dirname, 'components'),
  67. '~assets': path.join(__dirname, 'assets'),
  68. '~plugins': path.join(__dirname, 'plugins'),
  69. '~store': path.join(__dirname, 'store')
  70. })
  71. // nuxt ^2.00 版本后,webpack HtmlWebpackPlguin插件打包 会存在htlm5不能转换的问题
  72. // 已经命令是将 该插件 压缩部分进行重新处理
  73. for (let i = 0; i < config.plugins.length; i++) {
  74. if (config.plugins[i] && config.plugins[i].options && config.plugins[i].options.minify) {
  75. config.plugins[i].options.minify = {
  76. removeAttributeQuotes: true,
  77. collapseWhitespace: true,
  78. html5: true,
  79. minifyCSS: true,
  80. removeComments: true,
  81. removeEmptyAttributes: true,
  82. }
  83. }
  84. }
  85. // config.resolve.alias['~utils'] = path.join(__dirname, 'utils')
  86. // config.resolve.alias['~components'] = path.join(__dirname, 'components')
  87. // config.resolve.alias['assets'] = path.join(__dirname, './assets')
  88. // config.resolve.alias['~plugins'] = path.join(__dirname, 'plugins')
  89. // config.resolve.alias['~store'] = path.join(__dirname, 'store')
  90. // config.module.rules.push({
  91. // test: /\.scss$/,
  92. // loader: 'vue-style-loader!css-loader!sass-loader'
  93. // })
  94. // config.module.rules.push({
  95. // test: /\.js$/,
  96. // loader: 'babel-loader'
  97. // })
  98. // if (isClient) {
  99. // config.module.rules.push({
  100. // enforce: 'pre',
  101. // test: /\.(js|vue)$/,
  102. // loader: "eslint-loader",
  103. // exclude: /node_modules/
  104. // })
  105. // }
  106. },
  107. vendor: [
  108. 'axios',
  109. 'element-ui',
  110. 'mint-ui',
  111. 'vuerify',
  112. 'vee-validate'
  113. ],
  114. babel: {
  115. presets: ['@nuxt/babel-preset-app']
  116. }
  117. // postcss: [
  118. // require('autoprefixer')({
  119. // browsers: ['last 3 versions']
  120. // })
  121. // ]
  122. },
  123. css: [{
  124. src: '~assets/scss/mobileCommon.scss',
  125. lang: 'scss'
  126. },
  127. {
  128. src: '~assets/scss/app.scss',
  129. lang: 'scss'
  130. }
  131. ],
  132. dev: !isProdMode,
  133. env: {
  134. baseUrl,
  135. },
  136. plugins: [
  137. // {
  138. // src: '~plugins/axios-nuxt.js'
  139. // },
  140. // {
  141. // src: '~plugins/axios.js'
  142. // },
  143. {
  144. src: '~plugins/element-ui.js'
  145. }, {
  146. src: '~plugins/mint-ui.js'
  147. }, {
  148. src: '~plugins/filters.js',
  149. ssr: false
  150. }, {
  151. src: '~plugins/jsonp.js',
  152. ssr: false
  153. }, {
  154. src: '~plugins/vuerify.js',
  155. ssr: false
  156. }, {
  157. src: '~plugins/vee-validate.js',
  158. ssr: true
  159. }
  160. ],
  161. /* TODO 代理 */
  162. proxyTable: ['/api/**', '/login/**', '/user**', '/logout**', '/sso/**', '/appeal/**', '/update/user/**', '/valid/**', '/im/**', '/weChat/**', '/bh/**', '/foreign/**']
  163. }