Skip to content

Vue config Externals Array Syntax does not work #4413

Closed
@johannes-z

Description

@johannes-z

Version

4.0.0-alpha.5

Environment info

System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
  Binaries:
    Node: 11.13.0
    Yarn: 1.16.0
    npm: 6.7.0
  Browsers:
    Edge: 44.18362.1.0
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

Using a vue.config.js like this:

module.exports = {
  chainWebpack: config => {
    config.externals([
      /@namespace/,
      {
        'jquery': 'jquery',
        'test': 'test',
      },
    ])
  },
}

What is expected?

All the config.externals should be externalized.

What is actually happening?

None of the libraries are externalized, because vue-cli (?) changes the externals to:

{ '0': /@namespace/,
  '1': { jquery: 'jquery', test: 'test' },
  vue: { commonjs: 'vue', commonjs2: 'vue', root: 'Vue' } }

This causes the node_modules\webpack\lib\ExternalModuleFactoryPlugin.jsto ignore the externals.


I'm not sure if this is caused by the cli or by webpack-chain, but since vue-cli is adding the vue property to the object, I'm guessing that it's vue-cli's doing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions