vue.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const webpack = require('webpack')
  2. const fs = require('fs')
  3. const path = require('path')
  4. module.exports = {
  5. publicPath: "./",
  6. lintOnSave: false,
  7. productionSourceMap: false,
  8. css: {
  9. loaderOptions: {
  10. less: {
  11. // globalVars: getLessVariables(path.resolve(__dirname, './src/assets/style/globalVars.less'))
  12. }
  13. }
  14. },
  15. configureWebpack: {
  16. plugins: [
  17. new webpack.ProvidePlugin({
  18. globalMapState: ['vuex', 'mapState'],
  19. globalMapMutations: ['vuex', 'mapMutations'],
  20. globalMapGetters: ['vuex', 'mapGetters'],
  21. globalConfig: ['/src/config.js', 'default'],
  22. globalApi: ['/src/api.js', 'default'],
  23. globalUtils: ['/src/utils/index.js', 'default'],
  24. }),
  25. ],
  26. },
  27. devServer: {
  28. inline: false,
  29. hot: true,
  30. liveReload: false,
  31. port: 8081,
  32. proxy: {
  33. '/YHT': {
  34. target: 'http://yuhuatai.4dage.com',
  35. changeOrigin: true,
  36. },
  37. '/YHTM': {
  38. target: 'http://yuhuatai.4dage.com',
  39. changeOrigin: true,
  40. }
  41. },
  42. }
  43. }
  44. function getLessVariables(file) {
  45. var themeContent = fs.readFileSync(file, 'utf-8')
  46. var variables = {}
  47. themeContent.split('\n').forEach(function(item) {
  48. if (item.indexOf('//') > -1 || item.indexOf('/*') > -1) {
  49. return
  50. }
  51. var _pair = item.split(':')
  52. if (_pair.length < 2) return
  53. var key = _pair[0].replace('\r', '').replace('@', '')
  54. if (!key) return
  55. var value = _pair[1].replace(';', '').replace('\r', '').replace(/^\s+|\s+$/g, '')
  56. variables[key] = value
  57. })
  58. return variables
  59. }