多租户商城-商户端
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.

165 lines
5.1 KiB

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