react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

How can I set webpack proxy in cfg/base.js #347

Open Anoiing opened 6 years ago

Anoiing commented 6 years ago

const path = require('path'); const defaultSettings = require('./defaults');

const additionalPaths = []; // Remote target const targetServiceUrl = 'http://xxxxxxxxxxxxxxxxx';

module.exports = { additionalPaths, port: defaultSettings.port, debug: true, devtool: 'eval', output: { path: path.join(__dirname, '/../dist/assets'), filename: 'app.js', publicPath: defaultSettings.publicPath, }, devServer: { contentBase: './src/', quiet: false, proxy: { '/api/': { target: targetServiceUrl, pathRewrite: { '^/api': '' }, secure: false, }, '/view/': { secure: false, bypass: () => '/index.html', }, }, }, resolve: { extensions: ['', '.js', '.jsx'], alias: { assets: ${defaultSettings.srcPath}/assets/, components: ${defaultSettings.srcPath}/components/, stores: ${defaultSettings.srcPath}/stores/, utils: ${defaultSettings.srcPath}/utils/, config: ${defaultSettings.srcPath}/config/${process.env.REACT_WEBPACK_ENV}, 'react/lib/ReactMount': 'react-dom/lib/ReactMount', }, }, module: {}, };

Here is my base.js, but it doesn't work,help!