Tencent / wepy

小程序组件化开发框架
https://wepyjs.gitee.io/wepy-docs/
Other
22.48k stars 3.06k forks source link

wepy^1.7 wepy.config.js proxy配置项有吗 #2267

Open lijiahao8898 opened 4 years ago

lijiahao8898 commented 4 years ago

Description

wepy.config.js 配置代理[类似于webpack那种proxy]

 proxy: {
        '/api':{
            target: ',
            changeOrigin: true,
            pathRewrite: {
                '^/api' : '',
            }
        },
    },

Environment

Reproduce

Observed Results

无法生效

Expected Results

Relevant Code / Logs


const path = require('path');
var prod = process.env.NODE_ENV === 'production';

module.exports = {
  wpyExt: '.wpy',
  eslint: false,
  cliLogs: !prod,
    proxy: {
        '/api/':{
            target: '',
            changeOrigin: true,
            pathRewrite: {
                '^/api/' : '/',
            }
        },
    },
  build: {
    web: {
      htmlTemplate: path.join('src', 'index.template.html'),
      htmlOutput: path.join('web', 'index.html'),
      jsOutput: path.join('web', 'index.js')
    }
  },
  resolve: {
    alias: {
      counter: path.join(__dirname, 'src/components/counter'),
      '@': path.join(__dirname, 'src')
    },
    aliasFields: ['wepy', 'weapp'],
    modules: ['node_modules']
  },
  compilers: {
    less: {
      compress: prod
    },
    /*sass: {
      outputStyle: 'compressed'
    },*/
    babel: {
      sourceMap: true,
      presets: [
        'env'
      ],
      plugins: [
        'transform-class-properties',
        'transform-decorators-legacy',
        'transform-object-rest-spread',
        'transform-export-extensions',
      ]
    }
  },
  plugins: {
  },
  appConfig: {
    noPromiseAPI: ['createSelectorQuery']
  }
}

if (prod) {

  // 压缩sass
  // module.exports.compilers['sass'] = {outputStyle: 'compressed'}

  // 压缩js
  module.exports.plugins = {
    uglifyjs: {
      filter: /\.js$/,
      config: {
      }
    },
    imagemin: {
      filter: /\.(jpg|png|jpeg)$/,
      config: {
        jpg: {
          quality: 80
        },
        png: {
          quality: 80
        }
      }
    }
  }
}

  ```
Gcaufy commented 4 years ago

暂时不支持,不过可以通过插件支持到,欢迎 PR