title: Nuxt 2.x: Add babel's transform plugin, that work on imported node_module file
body: <p>How to add <code>@babel/plugin-proposal-optional-chaining</code> plugin to <code>.nuxt.config</code> that work for a file imported from <code>node_modules</code> (a one that not pre-build )</p>
  
  <p>By this Example <a href="http://Follow%20by%20that%20example:" rel="nofollow noreferrer">here</a> I do: </p>
  
  <pre><code>export default {
    plugins: [
          '~/plugins/accesso.js' // that one make the trouble
    ],
    build: {
     babel: {
       plugins: [
          ['@babel/plugin-proposal-optional-chaining', {loose: true}]
       ]
     }
   }
  }
  </code></pre>
  
  <pre class="lang-js prettyprint-override"><code>// ~/plugins/accesso.js
  import Accesso from '@perymimon/accesso'
  
  export default function (ctx, inject) {
      inject('Accesso', accesso)
  }
  
  </code></pre>
  
  <p>And it works fine for some <code>foo?.bar</code> in <code>.vue</code> files but not for files that come from <code>node_module</code>.</p>
  
  <p>why?</p>
  
  <p>
  The eror is reguar error from webpack</p>
  
  <pre class="lang-js prettyprint-override"><code>Module parse failed: Unexpected token (311:25)                                                                                                                                                 friendly-errors 14:39:06
  You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
  |
  | function frame$extractPayload(frame, authSetting) {
  &gt;     let location = frame?.contentWindow?.location || frame.location;
  |     const {protocol, host, pathname} = location;
  |     const atHome = protocol + '//' + host + pathname === authSetting.redirect_uri;
                                                                                                                                                                                                 friendly-errors 14:39:06
   @ ./node_modules/@perymimon/accesso/src/providers.js 1:0-37 3:0-29 3:0-29 8:22-29 34:23-30 51:22-29
   @ ./plugins/accesso.js
   @ ./.nuxt/index.js
   @ ./.nuxt/client.js
   @ multi eventsource-polyfill webpack-hot-middleware/client?reload=true&amp;timeout=30000&amp;ansiColors=&amp;overlayStyles=&amp;name=modern&amp;path=/__webpack_hmr/modern ./.nuxt/client.js
  </code></pre>
  
  <p></p>