netlify / vue-cli-plugin-netlify-lambda

Netlify Lambda plugin for Vue CLI
76 stars 12 forks source link

Webpack configuration is ignored #4

Open jmotes opened 5 years ago

jmotes commented 5 years ago

I'm needing to apply this to my webpack config to solve a problem with using FaunaDB in my functions:

https://github.com/felixge/node-formidable/issues/337#issuecomment-264337905

Chris Coyier did it this way in his React project, but I cannot seem to get it to work in my vue.config.js.

https://github.com/chriscoyier/netlify-faunadb-example/blob/master/webpack.config.js

Here's my vue.config.js with everything set up, but it seems as if it's completely ignored when building the function:

const webpack = require("webpack");

module.exports = {
  configureWebpack: {
    plugins: [
      new webpack.DefinePlugin({
        "global.GENTLY": false
      })
    ],
    node: {
      __dirname: true,
    },
    resolve: {
      alias: {
        'inherits': 'inherits/inherits_browser.js',
        'superagent': 'superagent/lib/client',
        'emitter': 'component-emitter',
      }
    }
  }
}
jmotes commented 5 years ago

@cruzdanilo is this what your pull request (https://github.com/netlify/vue-cli-plugin-netlify-lambda/pull/3/) solves?

swyxio commented 5 years ago

cc @shortdiv

cruzdanilo commented 5 years ago

@jmotes yes, it is.

jmotes commented 5 years ago

@shortdiv if you could find time to review @cruzdanilo's pull request I will buy you a coffee 😄☕️.

e0 commented 5 years ago

I appreciate the #3 PR, but for this specific formidable problem I didn't manage to figure out how to override the global.GENTLY plugin using vue.config.js.

I ended up forking the node-formidable package and removed all the if (global.GENTLY) require = GENTLY.hijack(require); lines which are causing the problems and perfectly safe to remove from what I can see. Then as I'm using yarn I could enforce this forked nested dependency in package.json like so:

...
 "dependencies": {
   ...
   "formidable": "https://github.com/e0/node-formidable",
   ...
 },
 "resolutions": {
   "formidable": "https://github.com/e0/node-formidable"
 },
...