Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arichardsmith opened this issue May 25, 2017 · 0 comments

Comments

@arichardsmith
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant