vue.config.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. let targetUrl = 'http://admin.dayaedu.com'
  2. // let targetUrl = 'http://dyme.utools.club'
  3. // let targetUrl = 'http://192.168.3.27:8000' // 箭河
  4. // let targetUrl = 'http://192.168.3.48:8000'
  5. // let targetUrl = 'http://testadm.dayaedu.com/'
  6. // let targetUrl = 'https://mstuonline.dayaedu.com'
  7. // let version = '1.0.0'
  8. // webpack.prod.conf.js
  9. // const Version = new Date().getTime();
  10. // const Version = 20191227;
  11. const CompressionWebpackPlugin = require('compression-webpack-plugin')
  12. const productionGzipExtensions = ['js', 'css']
  13. module.exports = {
  14. publicPath: './',
  15. // outputDir: 'dist',
  16. // assetsDir: 'static',
  17. // outputDir: 'dist',
  18. // 调整内部的 webpack 配置。
  19. // 查阅 https://github.com/vuejs/vue-doc-zh-cn/vue-cli/webpack.md
  20. // chainWebpack: () => {},
  21. // transpileDependencies: ['webpack-dev-server/client'],
  22. chainWebpack: config => {
  23. config.devtool('inline-source-map')
  24. config.output.filename('[name].[hash].js').end();
  25. // // chunkHash
  26. // config.output.filename(`js/[name].[chunkhash].${Version}.js`).end();
  27. // config.output.chunkFilename(`js/[id].[chunkhash].${Version}.js`).end();
  28. // config.output.filename(`js/[name].[chunkhash].js`).end();
  29. // config.output.chunkFilename(`js/[id].[chunkhash].js`).end();
  30. // config.entry.app = ['babel-polyfill', './src/main.js']
  31. // config.resolve.symlinks(true)
  32. // config.plugin('html').tap(args => {
  33. // args[0].chunksSortMode = 'none'
  34. // return args
  35. // })
  36. config.plugin('html').tap(args => {
  37. args[0].minify = {
  38. removeAttributeQuotes: false
  39. }
  40. return args
  41. })
  42. },
  43. // eslint-loader 是否在保存的时候检查
  44. lintOnSave: true,
  45. // 是否使用包含运行时编译器的Vue核心的构建
  46. runtimeCompiler: false,
  47. // 生产环境 sourceMap
  48. productionSourceMap: false,
  49. // productionGzip: true,
  50. configureWebpack: (config) => {
  51. // process.env.NODE_ENV === 'production'
  52. // 生产环境
  53. config.plugins.push(
  54. new CompressionWebpackPlugin({
  55. filename: '[path].gz[query]', // 提示示compression-webpack-plugin@3.0.0的话asset改为filename
  56. algorithm: 'gzip',
  57. test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  58. threshold: 10240,
  59. minRatio: 0.8
  60. })
  61. )
  62. },
  63. // 配置 webpack-dev-server 行为。
  64. devServer: {
  65. open: process.platform === 'darwin',
  66. host: '0.0.0.0',
  67. port: 9002,
  68. https: false,
  69. hotOnly: false,
  70. // 查阅 https://github.com/vuejs/vue-doc-zh-cn/vue-cli/cli-service.md#配置代理
  71. proxy: {
  72. '/contracts': {
  73. target: targetUrl,
  74. changeOrigin: true,
  75. ws: true,
  76. '^/contracts': '/contracts',
  77. xfwd: true
  78. },
  79. '/student-server': {
  80. target: targetUrl,
  81. changeOrigin: true,
  82. ws: true,
  83. '^/student-server': '/student-server',
  84. xfwd: true
  85. },
  86. '/api-cms': {
  87. target: targetUrl,
  88. changeOrigin: true,
  89. ws: true,
  90. '^/api-cms': '/api-cms',
  91. xfwd: true
  92. },
  93. '/api-student': {
  94. target: targetUrl,
  95. changeOrigin: true,
  96. ws: true,
  97. '^/api-student': '/api-student',
  98. xfwd: true
  99. },
  100. '/api-auth': {
  101. target: targetUrl,
  102. changeOrigin: true,
  103. ws: true,
  104. '^/api-auth': '/api-auth',
  105. xfwd: true
  106. },
  107. '/musicGroup': {
  108. target: targetUrl,
  109. changeOrigin: true,
  110. ws: true,
  111. '^/musicGroup': '/musicGroup',
  112. xfwd: true
  113. }
  114. }, // string | Object
  115. },
  116. css: {
  117. loaderOptions: {
  118. less: {
  119. modifyVars: {
  120. // red: '#03a9f4',
  121. blue: '#14928A',
  122. // orange: '#f08d49',
  123. // 'text-color': '#111'
  124. }
  125. }
  126. }
  127. },
  128. }