Open ItsJonQ opened 5 years ago
Great idea, I really like it. I'm not sure if maybe the functions should just be added to the Webpack config.... (then of course they could always be imported via a file. Meaning, I think there would have to be some glue in the plugin), kinda like this:
new ProxyPackPlugin({
browser: 'chrome',
domain: 'https://secure.helpscout.net',
webpackMappings: ['https://*.cloudfront.net/*/js/apps/dist/*'],
mocks: [
('some-url', (req, res) => {
const { data: originalData } = req
return {
...originalData,
extraStuff: 'weeeee',
status: 200
}
}),
('some-other-url', (req, res) => {
const { data: originalData } = req
return {
status: 404
}
})
]
})
Just an idea! I shared this with @tjbo yesterday when we 🍐 'ed.
What if.. there was a way to provide ProxyPack's webpack setup with a file.. maybe
functions.js
or something.And within that file, you'd have something like:
This will allow us to adjust/test/mock data when developing. If proxypack + webpack could watch this file, we can update it while webpack serve is up!
How neat would that be :)
P.S. The above implementation was inspired by serverless cloud function like APIs (specifically Google/Firebase Cloud Functions. I'm most familiar with those)