Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
baitu.huang
committed
Jul 18, 2019
1 parent
35bf29e
commit 0546611
Showing
4 changed files
with
27 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
const loaderUtils = require('loader-utils') | ||
const { RESOLVED_FLAGS_PATH, IF_FLAG } = require('./constants') | ||
const ifDirReg = new RegExp(`\\s${IF_FLAG}(?:\\s*(=)\\s*(?:"([^"]+)"+|'([^']+)'+|([^\\s"'=<>\`]+)))`) | ||
const hotReloadRegs = [/module\.hot\.accept\(/, /module\.hot\.data/, /vue/] | ||
// const hotReloadRegs = [/module\.hot\.accept\(/, /module\.hot\.data/, /vue/] | ||
|
||
module.exports = function vueFlagsTemplateLoader (source, map) { | ||
let vue, type | ||
const { watch } = loaderUtils.getOptions(this) | ||
if (!watch) { | ||
return this.callback(null, source, map) | ||
} | ||
// let vue, type | ||
// const { watch } = loaderUtils.getOptions(this) | ||
// if (!watch) { | ||
// return this.callback(null, source, map) | ||
// } | ||
if (this.resourceQuery) { | ||
({ vue, type } = loaderUtils.parseQuery(this.resourceQuery)) | ||
} | ||
if (vue && type === 'template' && ifDirReg.test(source)) { | ||
this.addDependency(RESOLVED_FLAGS_PATH) | ||
} | ||
if (!type && this.hot && hotReloadRegs.every(r => r.test(source))) { | ||
// create component hot reload record by removing `module.hot.data`, see `vue-hot-reload-api` | ||
source = 'module.hot && module.hot.data && module.hot.data.__vue_component_hot__ && (module.hot.data = undefined);\n' + source | ||
const { vue, type } = loaderUtils.parseQuery(this.resourceQuery) | ||
if (vue && type === 'template' && ifDirReg.test(source)) { | ||
this.addDependency(RESOLVED_FLAGS_PATH) | ||
} | ||
} | ||
// if (!type && this.hot && hotReloadRegs.every(r => r.test(source))) { | ||
// // create component hot reload record by removing `module.hot.data`, see `vue-hot-reload-api` | ||
// source = 'module.hot && module.hot.data && module.hot.data.__vue_component_hot__ && (module.hot.data = undefined);\n' + source | ||
// } | ||
this.callback(null, source, map) | ||
} |