vue.config.js 5.8 KB

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