const fs = require('fs'); const path = require('path'); module.exports = { publicPath: "./", css: { loaderOptions: { less: { globalVars: getLessVariables(path.resolve(__dirname, './src/assets/css/globalVars.less')) } } }, devServer: { proxy: { '/data': { target: 'http://192.168.0.44:8110', changeOrigin: true, // pathRewrite: { // '^/api': '/api' // } } } } }; function getLessVariables(file) { var themeContent = fs.readFileSync(file, 'utf-8') var variables = {} themeContent.split('\n').forEach(function (item) { if (item.indexOf('//') > -1 || item.indexOf('/*') > -1) { return } var _pair = item.split(':') if (_pair.length < 2) return; var key = _pair[0].replace('\r', '').replace('@', '') if (!key) return; var value = _pair[1].replace(';', '').replace('\r', '').replace(/^\s+|\s+$/g, '') variables[key] = value }) return variables }