Rollup plugin to serve the bundle and proxy http
Installation
# Rollup v>2+
npm install --save-dev rollup-plugin-express-proxy
Usage
import serve from 'rollup-plugin-express-proxy'
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: ...
},
plugins: [
serve({
port: 8080,
contentBase: path.resolve(__dirname, "../public"),
proxy: {
"api": {
destination: "http://baidu.com",
test: "/api",
proxyReqOptDecorator:function(proxyReqOpts, srcReq) {
return proxyReqOpts;
},
proxyReqPathResolver:function(req, res) {
return req.originalUrl;
}
}
}
})
]
}
Options
By default it serves the current project folder. Change it by passing a string:
serve({
open: true,
openPage: '/different/page',
contentBase: '',
historyApiFallback: '/200.html',
port: 10001,
proxy: {
api: 'http://localhost:8181'
}
})