多租户商城-平台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
5.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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 || 'vue Admin Template' // 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. // All configuration item explanations can be find in https://cli.vuejs.org/config/
  15. module.exports = {
  16. /**
  17. * You will need to set publicPath if you plan to deploy your site under a sub path,
  18. * for example GitHub Pages. If you plan to deploy your site to https://foo.github.io/bar/,
  19. * then publicPath should be set to "/bar/".
  20. * In most cases please use '/' !!!
  21. * Detail: https://cli.vuejs.org/config/#publicpath
  22. */
  23. runtimeCompiler: true,
  24. publicPath: './',
  25. outputDir: 'dist',
  26. assetsDir: 'static',
  27. lintOnSave: process.env.NODE_ENV === 'development',
  28. productionSourceMap: false,
  29. devServer: {
  30. port: port,
  31. open: false,
  32. overlay: {
  33. warnings: false,
  34. errors: true
  35. },
  36. // before: require('./mock/mock-server.js'),
  37. proxy: {
  38. '/api': {
  39. // target: 'http://3j073r3905.qicp.vip:29544', // 测试
  40. // target: 'https://ceresdev.zkthink.com/adminapi', // 平台端
  41. target: 'http://122.9.152.120/ceres-admin-api', // 平台端
  42. // target: 'https://bizapi.zkthink.com', // 商家端
  43. changeOrigin: true,
  44. pathRewrite: {
  45. '^/api': ''
  46. }
  47. },
  48. '/adminapi': {
  49. // target: 'http://3j073r3905.qicp.vip:29544', // 测试
  50. // target: 'https://ceresdev.zkthink.com/adminapi', // 平台端
  51. target: 'http://122.9.152.120/ceres-admin-api', // 平台端
  52. // target: 'https://bizapi.zkthink.com', // 商家端
  53. changeOrigin: true,
  54. pathRewrite: {
  55. '^/adminapi': ''
  56. }
  57. },
  58. '/': {
  59. // target: 'http://3j073r3905.qicp.vip:29544', // 测试
  60. // target: 'https://ceresdev.zkthink.com/adminapi/', // 平台端
  61. target: 'http://122.9.152.120/ceres-admin-api', // 平台端
  62. // target: 'https://bizapi.zkthink.com', // 商家端
  63. changeOrigin: true,
  64. },
  65. }
  66. },
  67. configureWebpack: {
  68. // provide the app's title in webpack's name field, so that
  69. // it can be accessed in index.html to inject the correct title.
  70. name: name,
  71. resolve: {
  72. alias: {
  73. '@': resolve('src'),
  74. '@@': resolve('canvas-container')
  75. }
  76. }
  77. },
  78. // 配置全局样式变量
  79. css: {
  80. loaderOptions: {
  81. sass: {
  82. prependData: `@import "canvas-container/styles/index.scss";`
  83. }
  84. }
  85. },
  86. // 配置多页面入口
  87. pages: {
  88. index: {
  89. entry: 'src/main.js',
  90. template: 'public/index.html',
  91. filename: 'index.html',
  92. chunks: ['chunk-elementUI', 'chunk-vendors', 'chunk-libs', 'runtime', 'index']
  93. },
  94. canvas: {
  95. entry: 'canvas-container/main.js',
  96. template: 'public/canvas.html',
  97. filename: 'canvas.html',
  98. chunks: ['chunk-elementUI', 'chunk-vendors', 'chunk-libs', 'runtime', 'canvas']
  99. }
  100. },
  101. chainWebpack(config) {
  102. // it can improve the speed of the first screen, it is recommended to turn on preload
  103. // config.plugin('preload').tap(() => [
  104. // {
  105. // rel: 'preload',
  106. // // to ignore runtime.js
  107. // // https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/cli-service/lib/config/app.js#L171
  108. // fileBlacklist: [/\.map$/, /hot-update\.js$/, /runtime\..*\.js$/],
  109. // include: 'initial'
  110. // }
  111. // ])
  112. // when there are many pages, it will cause too many meaningless requests
  113. config.plugins.delete('prefetch')
  114. // set svg-sprite-loader
  115. config.module
  116. .rule('svg')
  117. .exclude.add(resolve('src/icons'))
  118. .end()
  119. config.module
  120. .rule('icons')
  121. .test(/\.svg$/)
  122. .include.add(resolve('src/icons'))
  123. .end()
  124. .use('svg-sprite-loader')
  125. .loader('svg-sprite-loader')
  126. .options({
  127. symbolId: 'icon-[name]'
  128. })
  129. .end()
  130. config
  131. .when(process.env.NODE_ENV !== 'development',
  132. config => {
  133. config
  134. .plugin('ScriptExtHtmlWebpackPlugin')
  135. .after('html')
  136. .use('script-ext-html-webpack-plugin', [{
  137. // `runtime` must same as runtimeChunk name. default is `runtime`
  138. inline: /runtime\..*\.js$/
  139. }])
  140. .end()
  141. config
  142. .optimization.splitChunks({
  143. chunks: 'all',
  144. cacheGroups: {
  145. libs: {
  146. name: 'chunk-libs',
  147. test: /[\\/]node_modules[\\/]/,
  148. priority: 10,
  149. chunks: 'initial' // only package third parties that are initially dependent
  150. },
  151. elementUI: {
  152. name: 'chunk-elementUI', // split elementUI into a single package
  153. priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
  154. test: /[\\/]node_modules[\\/]_?element-ui(.*)/ // in order to adapt to cnpm
  155. },
  156. commons: {
  157. name: 'chunk-commons',
  158. test: resolve('src/components'), // can customize your rules
  159. minChunks: 3, // minimum common number
  160. priority: 5,
  161. reuseExistingChunk: true
  162. }
  163. }
  164. })
  165. // https:// webpack.js.org/configuration/optimization/#optimizationruntimechunk
  166. config.optimization.runtimeChunk('single')
  167. }
  168. )
  169. }
  170. }