vue.config.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. const path = require('path')
  2. const webpack = require('webpack')
  3. const createThemeColorReplacerPlugin = require('./config/plugin.config')
  4. const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
  5. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
  6. var baseURL = process.env.VUE_APP_API_CTX_PATH
  7. //生产环境下打包保留debugger
  8. //const TerserPlugin = require('terser-webpack-plugin')
  9. //生产环境下组件获取路径 __file ;
  10. const VueFilenameInjector = require('@d2-projects/vue-filename-injector')
  11. function resolve (dir) {
  12. return path.join(__dirname, dir)
  13. }
  14. // webpack build externals
  15. const prodExternals = {
  16. // key表示包名(import foo from 'xx' 里的xx)
  17. // value表示window下的全局变量名(库暴露出来的namespace,可查lib对应的webpack配置里的library字段)
  18. 'vue': 'Vue',
  19. 'axios': 'axios',
  20. 'vue-router': 'VueRouter',
  21. 'vuex': 'Vuex',
  22. /*'jpaas-common-lib': 'jpaas-commons',*/
  23. 'moment': 'moment',
  24. '@antv/g2': 'G2',
  25. '@antv/data-set': 'DataSet',
  26. 'ant-design-vue': 'antd'
  27. }
  28. // publicPath: "/jpaas",
  29. // vue.config.js
  30. const vueConfig = {
  31. publicPath: baseURL,
  32. configureWebpack: {
  33. externals: prodExternals,
  34. plugins: [
  35. // Ignore all locale files of moment.js
  36. new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  37. new webpack.IgnorePlugin(/moment\//),
  38. new webpack.ProvidePlugin({
  39. 'window.Quill': 'quill/dist/quill.js',
  40. 'Quill': 'quill/dist/quill.js'
  41. })
  42. // new BundleAnalyzerPlugin()
  43. ]
  44. },
  45. assetsDir: 'static',
  46. chainWebpack: config => {
  47. // config.entry('polyfill').add('@babel/polyfill');
  48. config.resolve.alias.set('@$', resolve('src'))
  49. .set('@static', resolve('static'))
  50. .set('@img', resolve('static/img'))
  51. const svgRule = config.module.rule('svg')
  52. svgRule.uses.clear()
  53. svgRule
  54. .oneOf('inline')
  55. .resourceQuery(/inline/)
  56. .use('vue-svg-icon-loader')
  57. .loader('vue-svg-icon-loader')
  58. .end()
  59. .end()
  60. .oneOf('external')
  61. .use('file-loader')
  62. .loader('file-loader')
  63. .options({
  64. name: 'assets/[name].[hash:8].[ext]'
  65. })
  66. /*config.optimization.minimizer([//生产环境下保留debugger
  67. new TerserPlugin({
  68. terserOptions: {
  69. mangle: true,
  70. compress: {
  71. drop_debugger: false
  72. }
  73. }
  74. })
  75. ]
  76. )*/
  77. //公共代码抽离
  78. // config.optimization.splitChunks({
  79. // cacheGroups: {
  80. // // vendor: {
  81. // // chunks: 'initial',
  82. // // test: /node_modules/,
  83. // // name: 'vendor',
  84. // // minChunks: 1,
  85. // // maxInitialRequests: 5,
  86. // // minSize: 5*1024,
  87. // // priority: 5
  88. // // },
  89. // // common: {
  90. // // chunks: 'initial',
  91. // // test: /[\\/]src[\\/]js[\\/]/,
  92. // // name: 'common',
  93. // // minChunks: 2,
  94. // // maxInitialRequests: 5,
  95. // // minSize: 5*1024,
  96. // // priority: 1
  97. // // },
  98. // jpaasCommonLib: {
  99. // chunks: 'initial',
  100. // test: /[\\/]node_modules[\\/]jpaas-common-lib[\\/]/,
  101. // name: 'jpaas-common-lib',
  102. // maxInitialRequests: 5,
  103. // priority: 2
  104. // },
  105. // jpaasFormComponent: {
  106. // chunks: 'initial',
  107. // test: /[\\/]node_modules[\\/]jpaas-form-component[\\/]/,
  108. // name: 'jpaas-form-component',
  109. // maxInitialRequests: 5,
  110. // priority: 3
  111. // },
  112. // rxKFormDesign: {
  113. // chunks: 'initial',
  114. // test: /[\\/]node_modules[\\/]rx-k-form-design[\\/]/,
  115. // name: 'rx-k-form-design',
  116. // maxInitialRequests: 5,
  117. // priority: 4
  118. // },
  119. // // styles: {
  120. // // name: 'styles',
  121. // // test: /\.(sa|sc|c)ss$/,
  122. // // chunks: 'all',
  123. // // enforce: true
  124. // // },
  125. // // runtimeChunk: {
  126. // // name: 'manifest'
  127. // // }
  128. // }
  129. // })
  130. VueFilenameInjector(config, {
  131. propName: '__source' // default
  132. })
  133. },
  134. css: {
  135. loaderOptions: {
  136. less: {
  137. lessOptions: {
  138. javascriptEnabled: true
  139. }
  140. }
  141. }
  142. },
  143. devServer: {
  144. // development server port 8000
  145. port: 8002,
  146. disableHostCheck: true,
  147. proxy: {
  148. '/web-apps/': {
  149. //target: 'http://192.168.0.185:7206',//张哲
  150. target: 'http://www.hkcqjy.com.cn:8096',//服务器
  151. // target: 'http://10.5.100.64:5208',
  152. //target: 'http://192.168.0.176:7206',//柳哥
  153. // target: 'http://10.5.0.233:9900',
  154. // target: 'http://10.5.100.64:9900',
  155. pathRewrite: { '^/web-apps': '' },
  156. ws: false,
  157. changeOrigin: true
  158. },
  159. '/api-knowledge/': {
  160. //target: 'http://192.168.0.185:7206',//张哲
  161. //target: 'http://10.5.100.230:9009',//服务器
  162. // target: 'http://10.5.100.64:5208',
  163. //target: 'http://192.168.0.205:7206',//柳哥
  164. //target: 'http://10.5.100.101/',
  165. target: 'http://www.hkcqjy.com.cn:8088',
  166. //target: 'http://10.5.100.230:9009',//服务器
  167. // target: 'http://10.5.0.233:9900',
  168. // target: 'http://10.5.100.64:9900',
  169. pathRewrite: { '^api': '' },
  170. ws: false,
  171. changeOrigin: true
  172. },
  173. '/api': {
  174. // target: 'http://localhost:9900',
  175. // target: 'http://10.5.0.233:9900',
  176. //target: 'http://10.5.100.64:9900',
  177. //target: 'http://10.5.100.101/',
  178. target: 'http://www.hkcqjy.com.cn:8088',
  179. //target: 'http://10.5.100.64:5208',
  180. //target: 'http://192.168.0.176:7206',//柳哥
  181. //target: 'http://192.168.0.109:7206',//白哥
  182. pathRewrite: { '^api': '' },
  183. ws: false,
  184. changeOrigin: true
  185. }
  186. }
  187. },
  188. // disable source map in production
  189. productionSourceMap: false,
  190. lintOnSave: undefined,
  191. // babel-loader no-ignore node_modules/*
  192. transpileDependencies: []
  193. }
  194. // 如果你不想在生产环境开启换肤功能,请打开下面注释
  195. // if (process.env.VUE_APP_PREVIEW === 'true') {
  196. // add `ThemeColorReplacer` plugin to webpack plugins
  197. vueConfig.configureWebpack.plugins.push(createThemeColorReplacerPlugin())
  198. vueConfig.configureWebpack.plugins.push(new MonacoWebpackPlugin())
  199. // }
  200. module.exports = vueConfig