vue.config.js 6.3 KB

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