Skip to content

Webpack errors if run more than once due to vue-loader mutating config object #824

Closed
@arichardsmith

Description

@arichardsmith

Version

12.1.0

Reproduction link

https://github.com/arichardsmith/vue-loader-bug-report

Steps to reproduce

  • Clone the repo and install dependancies.
  • Run gulp dev
  • Edit any file in ./src

What is expected?

Gulp is watching the src directory and should run the build task without any errors.

What is actually happening?

Webpack errors on every build after the first with:

WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property '__vueOptions__'.
  ......

It seems that vue-loader mutates the webpack config object here:

// /lib/loader.js line 52
var options = this.options.__vueOptions__ = Object.assign({}, this.options.vue, this.vue, query)

This introduces an option that webpack doesn't allow.
It isn't an issue if you are running webpack from the command line, but when you are using the API, the config object gets re-used for each call, giving the error.

Cloning your config object before you pass it to webpack avoids any of these problems:

webpack(config, callback) // bad

webpack(Object.assign({}, config), callback) // good

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions