vue-hot-reload-api

WebJar for vue-hot-reload-api

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

vue-hot-reload-api
Last Version

Last Version

2.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

vue-hot-reload-api
WebJar for vue-hot-reload-api
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/vuejs/vue-hot-reload-api

Download vue-hot-reload-api

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/vue-hot-reload-api/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>vue-hot-reload-api</artifactId>
    <version>2.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/vue-hot-reload-api/
implementation 'org.webjars.npm:vue-hot-reload-api:2.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/vue-hot-reload-api/
implementation ("org.webjars.npm:vue-hot-reload-api:2.3.0")
'org.webjars.npm:vue-hot-reload-api:jar:2.3.0'
<dependency org="org.webjars.npm" name="vue-hot-reload-api" rev="2.3.0">
  <artifact name="vue-hot-reload-api" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='vue-hot-reload-api', version='2.3.0')
)
libraryDependencies += "org.webjars.npm" % "vue-hot-reload-api" % "2.3.0"
[org.webjars.npm/vue-hot-reload-api "2.3.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

vue-hot-reload-api

Note: [email protected] only works with [email protected]

Hot reload API for Vue components. This is what vue-loader and vueify use under the hood.

Usage

You will only be using this if you are writing some build toolchain based on Vue components. For normal application usage, just use vue-loader or vueify.

// define a component as an options object
const myComponentOptions = {
  data () { ... },
  created () { ... },
  render () { ... }
}

// assuming Webpack's HMR API.
// https://webpack.js.org/guides/hot-module-replacement/
if (module.hot) {
  const api = require('vue-hot-reload-api')
  const Vue = require('vue')

  // make the API aware of the Vue that you are using.
  // also checks compatibility.
  api.install(Vue)

  // compatibility can be checked via api.compatible after installation
  if (!api.compatible) {
    throw new Error('vue-hot-reload-api is not compatible with the version of Vue you are using.')
  }

  // indicate this module can be hot-reloaded
  module.hot.accept()

  if (!module.hot.data) {
    // for each component option object to be hot-reloaded,
    // you need to create a record for it with a unique id.
    // do this once on startup.
    api.createRecord('very-unique-id', myComponentOptions)
  } else {
    // if a component has only its template or render function changed,
    // you can force a re-render for all its active instances without
    // destroying/re-creating them. This keeps all current app state intact.
    api.rerender('very-unique-id', myComponentOptions)

    // --- OR ---

    // if a component has non-template/render options changed,
    // it needs to be fully reloaded. This will destroy and re-create all its
    // active instances (and their children).
    api.reload('very-unique-id', myComponentOptions)
  }
}

License

MIT

org.webjars.npm

vuejs

Versions

Version
2.3.0