@@ -15,12 +15,6 @@ var selectorPath = 'vue-loader/lib/selector'
1515var templateLoader = 'vue-loader/lib/template-loader'
1616
1717module . exports = function ( content ) {
18- var defaultLoaders = {
19- html : 'vue-loader/lib/template-compiler' ,
20- css : 'vue-style-loader!css-loader' ,
21- js : 'babel-loader?presets[]=es2015&plugins[]=transform-runtime&comments=false'
22- }
23-
2418 this . cacheable ( )
2519 var loaderContext = this
2620 var options = this . options . vue || { }
@@ -30,6 +24,12 @@ module.exports = function (content) {
3024 var moduleId = '_v-' + hash ( filePath )
3125 var styleRewriter = 'vue-loader/lib/style-rewriter?id=' + moduleId
3226
27+ var defaultLoaders = {
28+ html : 'vue-loader/lib/template-compiler?id=' + moduleId ,
29+ css : 'vue-style-loader!css-loader' ,
30+ js : 'babel-loader?presets[]=es2015&plugins[]=transform-runtime&comments=false'
31+ }
32+
3333 // respect user babel options
3434 if ( this . options . babel ) {
3535 defaultLoaders . js = 'babel-loader'
@@ -127,7 +127,7 @@ module.exports = function (content) {
127127
128128 var parts = parse ( content , fileName , this . sourceMap )
129129 var hasScoped = false
130- var output = ''
130+ var output = 'var __vue_script__\n '
131131
132132 // add requires for styles
133133 parts . styles . forEach ( function ( style , i ) {
@@ -142,7 +142,7 @@ module.exports = function (content) {
142142 var script = parts . script
143143 if ( script ) {
144144 output +=
145- 'var __vue_script__ = ' + (
145+ '__vue_script__ = ' + (
146146 script . src
147147 ? getRequireForImport ( 'script' , script )
148148 : getRequire ( 'script' , script )
@@ -191,27 +191,26 @@ module.exports = function (content) {
191191 exports +
192192 'module.exports = __exports__'
193193 // hot reload
194- // if (
195- // !this.minimize &&
196- // process.env.NODE_ENV !== 'production' &&
197- // (parts.script.length || parts.template.length)
198- // ) {
199- // output +=
200- // 'if (module.hot) {(function () {' +
201- // ' module.hot.accept()\n' +
202- // ' var hotAPI = require("vue-hot-reload-api")\n' +
203- // ' hotAPI.install(require("vue"), false)\n' +
204- // ' if (!hotAPI.compatible) return\n' +
205- // ' var id = ' + loaderUtils.stringifyRequest(loaderContext, filePath) + '\n' +
206- // ' if (!module.hot.data) {\n' +
207- // // initial insert
208- // ' hotAPI.createRecord(id, module.exports)\n' +
209- // ' } else {\n' +
210- // // update
211- // ' hotAPI.update(id, module.exports, __vue_template__)\n' +
212- // ' }\n' +
213- // '})() }'
214- // }
194+ if (
195+ ! this . minimize &&
196+ process . env . NODE_ENV !== 'production' &&
197+ ( parts . script || parts . template )
198+ ) {
199+ output +=
200+ '\nif (module.hot) {(function () {' +
201+ ' var hotAPI = require("vue-hot-reload-api")\n' +
202+ ' hotAPI.install(require("vue"), false)\n' +
203+ ' if (!hotAPI.compatible) return\n' +
204+ ' module.hot.accept()\n' +
205+ ' if (!module.hot.data) {\n' +
206+ // initial insert
207+ ' hotAPI.createRecord("' + moduleId + '", __exports__)\n' +
208+ ' } else {\n' +
209+ // update
210+ ' hotAPI.reload("' + moduleId + '", __exports__)\n' +
211+ ' }\n' +
212+ '})()}'
213+ }
215214 } else {
216215 output +=
217216 'module.exports = function (injections) {\n' +
0 commit comments