vue.config.js 964 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const fs = require('fs');
  2. const path = require('path');
  3. process.env.VUE_APP_VERSION = require('./package.json').version
  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. };
  16. function getLessVariables(file) {
  17. var themeContent = fs.readFileSync(file, 'utf-8')
  18. var variables = {}
  19. themeContent.split('\n').forEach(function(item) {
  20. if (item.indexOf('//') > -1 || item.indexOf('/*') > -1) {
  21. return
  22. }
  23. var _pair = item.split(':')
  24. if (_pair.length < 2) return;
  25. var key = _pair[0].replace('\r', '').replace('@', '')
  26. if (!key) return;
  27. var value = _pair[1].replace(';', '').replace('\r', '').replace(/^\s+|\s+$/g, '')
  28. variables[key] = value
  29. })
  30. return variables
  31. }