Skip to content
This repository was archived by the owner on Sep 24, 2020. It is now read-only.

Commit 386992e

Browse files
committed
Clean-up hot reloading code
1 parent dc39542 commit 386992e

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## [v1.1.1] (2017-11-14)
4+
5+
**Fixes**
6+
7+
* Clean-up hot reloading code
8+
39
## [v1.1.0] (2017-11-09)
410

511
**Features**
@@ -134,6 +140,7 @@
134140
[#3]: https://github.com/ducksoupdev/vue-webpack-typescript/pull/3
135141
[#2]: https://github.com/ducksoupdev/vue-webpack-typescript/pull/2
136142
[#1]: https://github.com/ducksoupdev/vue-webpack-typescript/pull/1
143+
[v1.1.1]: https://github.com/ducksoupdev/vue-webpack-typescript/compare/v1.1.0...v1.1.1
137144
[v1.1.0]: https://github.com/ducksoupdev/vue-webpack-typescript/compare/v1.0.0...v1.1.0
138145
[v1.0.0]: https://github.com/ducksoupdev/vue-webpack-typescript/compare/v0.10.0...v1.0.0
139146
[v0.10.0]: https://github.com/ducksoupdev/vue-webpack-typescript/compare/v0.9.0...v0.10.0

template/config/webpack.config.base.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const helpers = require('./helpers'),
2+
NamedModulesPlugin = require('webpack/lib/NamedModulesPlugin'),
23
CopyWebpackPlugin = require('copy-webpack-plugin');
34

45
let config = {
@@ -38,6 +39,7 @@ let config = {
3839
],
3940
},
4041
plugins: [
42+
new NamedModulesPlugin(),
4143
new CopyWebpackPlugin([{
4244
from: 'src/assets',
4345
to: './assets'

template/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Vue from 'vue';
22
import VueRouter from 'vue-router';
3-
import { isHot, makeHot, reload } from './util/hot-reload';
3+
import { makeHot, reload } from './util/hot-reload';
44
import { createRouter } from './router';
55

66
const navbarComponent = () => import('./components/navbar').then(({ NavbarComponent }) => NavbarComponent);
77
// const navbarComponent = () => import(/* webpackChunkName: 'navbar' */'./components/navbar').then(({ NavbarComponent }) => NavbarComponent);
88

99
import './sass/main.scss';
1010

11-
if (process.env.ENV === 'development' && isHot()) {
11+
if (process.env.ENV === 'development' && module.hot) {
1212
const navbarModuleId = './components/navbar';
1313

1414
// first arguments for `module.hot.accept` and `require` methods have to be static strings

template/src/router.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Vue from 'vue';
22
import VueRouter, { Location, Route, RouteConfig } from 'vue-router';
3-
import { isHot, makeHot, reload } from './util/hot-reload';
3+
import { makeHot, reload } from './util/hot-reload';
44

55
const homeComponent = () => import('./components/home').then(({ HomeComponent }) => HomeComponent);
66
const aboutComponent = () => import('./components/about').then(({ AboutComponent }) => AboutComponent);
@@ -9,7 +9,7 @@ const listComponent = () => import('./components/list').then(({ ListComponent })
99
// const aboutComponent = () => import(/* webpackChunkName: 'about' */'./components/about').then(({ AboutComponent }) => AboutComponent);
1010
// const listComponent = () => import(/* webpackChunkName: 'list' */'./components/list').then(({ ListComponent }) => ListComponent);
1111

12-
if (process.env.ENV === 'development' && isHot()) {
12+
if (process.env.ENV === 'development' && module.hot) {
1313
const homeModuleId = './components/home';
1414
const aboutModuleId = './components/about';
1515
const listModuleId = './components/list';

template/src/util/hot-reload.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import Vue, { Component } from 'vue';
22
import * as api from 'vue-hot-reload-api';
33

4-
export const isHot = () => module.hot;
5-
64
export async function makeHot(id: string, componentLoader: () => Promise<Component>, acceptFunc: void) {
7-
if (isHot()) {
5+
if (module.hot) {
86
api.install(Vue);
97
if (!api.compatible) {
108
throw new Error('vue-hot-reload-api is not compatible with the version of Vue you are using.');

0 commit comments

Comments
 (0)