@@ -15,12 +15,6 @@ var selectorPath = 'vue-loader/lib/selector'
15
15
var templateLoader = 'vue-loader/lib/template-loader'
16
16
17
17
module . 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
-
24
18
this . cacheable ( )
25
19
var loaderContext = this
26
20
var options = this . options . vue || { }
@@ -30,6 +24,12 @@ module.exports = function (content) {
30
24
var moduleId = '_v-' + hash ( filePath )
31
25
var styleRewriter = 'vue-loader/lib/style-rewriter?id=' + moduleId
32
26
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
+
33
33
// respect user babel options
34
34
if ( this . options . babel ) {
35
35
defaultLoaders . js = 'babel-loader'
@@ -127,7 +127,7 @@ module.exports = function (content) {
127
127
128
128
var parts = parse ( content , fileName , this . sourceMap )
129
129
var hasScoped = false
130
- var output = ''
130
+ var output = 'var __vue_script__\n '
131
131
132
132
// add requires for styles
133
133
parts . styles . forEach ( function ( style , i ) {
@@ -142,7 +142,7 @@ module.exports = function (content) {
142
142
var script = parts . script
143
143
if ( script ) {
144
144
output +=
145
- 'var __vue_script__ = ' + (
145
+ '__vue_script__ = ' + (
146
146
script . src
147
147
? getRequireForImport ( 'script' , script )
148
148
: getRequire ( 'script' , script )
@@ -191,27 +191,26 @@ module.exports = function (content) {
191
191
exports +
192
192
'module.exports = __exports__'
193
193
// 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
+ }
215
214
} else {
216
215
output +=
217
216
'module.exports = function (injections) {\n' +
0 commit comments