vue-cli-plugin-browser-extension icon indicating copy to clipboard operation
vue-cli-plugin-browser-extension copied to clipboard

Configuring multiple background scripts gives error

Open Pithikos opened this issue 3 years ago • 2 comments

Describe the bug According to the documentation we should be able to have an array of background scripts like below

  pluginOptions: {
    browserExtension: {
      componentOptions: {
        background: {
          entry: ['src/background.js', 'src/background.test-harness.js']
        },
        contentScripts: {
          entries: {
            'content-script': [
              'src/content-scripts/content-script.js',
              'src/content-scripts/block-content.js',
            ]
          }
        }
      }
    }
  }

This however does not properly build with vue-cli-service build --mode development --watch as seen below

 ERROR  TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array

Any idea why this is the case?

Pithikos avatar Oct 28 '20 08:10 Pithikos

@Pithikos this is what I have in my vue.config.js and it works well (sorry for the formatting):

module.exports = { lintOnSave: false, pages: { popup: { template: "public/browser-extension.html", entry: "./src/popup/main.js", title: "Popup" } }, pluginOptions: { browserExtension: { componentOptions: { background: { entry: "src/background.js" }, contentScripts: { entries: { page: 'src/content-scripts/page.js', device: 'src/content-scripts/device.js', } } } } } };

mikestokes avatar Nov 19 '20 01:11 mikestokes

Same problem, my vue.config.js:

  lintOnSave: false,
  pages: {
    standalone: {
      template: 'public/browser-extension.html',
      entry: './src/standalone/main.js',
      title: 'Standalone',
      filename: 'index.html'
    }
  },

  pluginOptions: {
    browserExtension: {
      componentOptions: {
        background: {
          entry: ['src/background.js', 'src/axios.min.js']
        }
      }
    }
  },
}

Error:

 ERROR  TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array

N34AY avatar Jul 16 '21 21:07 N34AY