1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- 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.135:8001',
- changeOrigin: true,
- // pathRewrite: {
- // '^/api': '/api'
- // }
- }
- }
- },
- configureWebpack: {
- resolve: {
- alias: {
- '@': path.resolve(__dirname, 'src')
- }
- }
- },
- };
- 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
- }
|