vue.config.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. 'use strict'
  2. const path = require('path')
  3. const defaultSettings = require('./src/settings.js')
  4. function resolve (dir) {
  5. return path.join(__dirname, dir)
  6. }
  7. const name = defaultSettings.title || '管乐迷后台管理系统' // page title
  8. // If your port is set to 80,
  9. // use administrator privileges to execute the command line.
  10. // For example, Mac: sudo npm run
  11. // You can change the port by the following methods:
  12. // port = 9528 npm run dev OR npm run dev --port = 9528
  13. // const port = process.env.port || process.env.npm_config_port || 9528 // dev port
  14. // http://47.99.212.176:8000
  15. // // https://online.dayaedu.com
  16. // let target = 'https://online.dayaedu.com' //线上
  17. <<<<<<< HEAD
  18. let target = 'http://47.114.176.40:8000' //test环境
  19. // let target = 'http://192.168.3.139:8000' // 箭河
  20. // let target = 'http://192.168.3.38:8000' //邹璇
  21. // let target = 'http://192.168.3.57:8000' //勇哥
  22. // let target = 'http://47.114.176.40:8000' // 测试服
  23. // let target = 'http://dev.dayaedu.com/' // 乔
  24. =======
  25. // let target = 'http://192.168.3.139:8000' // 箭河
  26. // let target = 'http://192.168.3.38:8000' //邹璇
  27. // let target = 'http://192.168.3.57:8000' //勇哥
  28. // let target = 'http://dev.dayaedu.com' // 测试服
  29. let target = 'http://47.114.176.40:8000' //开发环境
  30. // let target = 'http://192.168.3.134' // 乔
  31. >>>>>>> origin/03/08IndexAtten
  32. // All configuration item explanations can be find in https://cli.vuejs.org/config/
  33. module.exports = {
  34. /**
  35. * You will need to set publicPath if you plan to deploy your site under a sub path,
  36. * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
  37. * then publicPath should be set to "/bar/".
  38. * In most cases please use '/' !!!
  39. * Detail: https://cli.vuejs.org/config/#publicpath
  40. */
  41. publicPath: './',
  42. outputDir: 'dist',
  43. assetsDir: 'static',
  44. lintOnSave: false,
  45. productionSourceMap: false,
  46. // 以下是pwa配置
  47. pwa: {
  48. iconPaths: {
  49. favicon32: 'favicon1.ico',
  50. favicon16: 'favicon1.ico',
  51. appleTouchIcon: 'favicon1.ico',
  52. maskIcon: 'favicon1.ico',
  53. msTileImage: 'favicon1.ico'
  54. }
  55. },
  56. devServer: {
  57. // port: 443,
  58. open: true,
  59. disableHostCheck: true,
  60. // overlay: {
  61. // warnings: false,
  62. // errors: true
  63. // },
  64. // https: true,
  65. proxy: {
  66. // change xxx-api/login => mock/login
  67. // detail: https://cli.vuejs.org/config/#devserver-proxy
  68. // http://47.99.212.176:8000
  69. // http://192.168.3.28:8000
  70. // http://192.168.3.134
  71. // http://47.114.176.40:8000
  72. '/api-auth': {
  73. target: 'http://192.168.3.134',
  74. changeOrigin: true,
  75. pathRewrite: {
  76. '^api-auth': ''
  77. }
  78. },
  79. '/api-task': {
  80. target: target,
  81. changeOrigin: true,
  82. pathRewrite: {
  83. '^api-task': ''
  84. }
  85. },
  86. '/api-web': {
  87. target: target,
  88. changeOrigin: true,
  89. pathRewrite: {
  90. '^api-web': ''
  91. }
  92. },
  93. '/api-cms': {
  94. target: target,
  95. changeOrigin: true,
  96. pathRewrite: {
  97. '^api-cms': ''
  98. }
  99. },
  100. '/api-teacher': {
  101. target: target,
  102. changeOrigin: true,
  103. pathRewrite: {
  104. '^api-teacher': ''
  105. }
  106. },
  107. '/jiari': {
  108. target: 'http://tool.bitefu.net',
  109. changeOrigin: true,
  110. },
  111. },
  112. },
  113. configureWebpack: {
  114. // provide the app's title in webpack's name field, so that
  115. // it can be accessed in index.html to inject the correct title.
  116. name: name,
  117. resolve: {
  118. alias: {
  119. '@': resolve('src')
  120. }
  121. }
  122. },
  123. chainWebpack (config) {
  124. config.plugins.delete('preload') // TODO: need test
  125. config.plugins.delete('prefetch') // TODO: need test
  126. // set svg-sprite-loader
  127. config.module
  128. .rule('svg')
  129. .exclude.add(resolve('src/icons'))
  130. .end()
  131. config.module
  132. .rule('icons')
  133. .test(/\.svg$/)
  134. .include.add(resolve('src/icons'))
  135. .end()
  136. .use('svg-sprite-loader')
  137. .loader('svg-sprite-loader')
  138. .options({
  139. symbolId: 'icon-[name]'
  140. })
  141. .end()
  142. // set preserveWhitespace
  143. config.module
  144. .rule('vue')
  145. .use('vue-loader')
  146. .loader('vue-loader')
  147. .tap(options => {
  148. options.compilerOptions.preserveWhitespace = true
  149. return options
  150. })
  151. .end()
  152. config
  153. // https://webpack.js.org/configuration/devtool/#development
  154. .when(process.env.NODE_ENV === 'development',
  155. config => config.devtool('cheap-source-map')
  156. )
  157. config
  158. .when(process.env.NODE_ENV !== 'development',
  159. config => {
  160. config
  161. .plugin('ScriptExtHtmlWebpackPlugin')
  162. .after('html')
  163. .use('script-ext-html-webpack-plugin', [{
  164. // `runtime` must same as runtimeChunk name. default is `runtime`
  165. inline: /runtime\..*\.js$/
  166. }])
  167. .end()
  168. config
  169. .optimization.splitChunks({
  170. chunks: 'all',
  171. cacheGroups: {
  172. libs: {
  173. name: 'chunk-libs',
  174. test: /[\\/]node_modules[\\/]/,
  175. priority: 10,
  176. chunks: 'initial' // only package third parties that are initially dependent
  177. },
  178. elementUI: {
  179. name: 'chunk-elementUI', // split elementUI into a single package
  180. priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
  181. test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
  182. },
  183. commons: {
  184. name: 'chunk-commons',
  185. test: resolve('src/components'), // can customize your rules
  186. minChunks: 3, // minimum common number
  187. priority: 5,
  188. reuseExistingChunk: true
  189. }
  190. }
  191. })
  192. config.optimization.runtimeChunk('single')
  193. }
  194. )
  195. }
  196. }