@@ -3,6 +3,7 @@ var assign = require('object-assign')
33var parse = require ( './parser' )
44var hash = require ( 'hash-sum' )
55var path = require ( 'path' )
6+ var normalizeDepPath = require ( './normalize-dep' )
67
78var defaultLang = {
89 template : 'html' ,
@@ -12,7 +13,9 @@ var defaultLang = {
1213
1314var rewriterInjectRE = / \b ( c s s (?: - l o a d e r ) ? (?: \? [ ^ ! ] + ) ? ) (?: ! | $ ) /
1415var selectorPath = 'vue-loader/lib/selector'
15- var templateLoader = 'vue-loader/lib/template-loader'
16+ var templateLoaderPath = 'vue-loader/lib/template-loader'
17+ var styleLoaderPath = normalizeDepPath ( 'vue-style-loader' )
18+ var hotReloadAPIPath = normalizeDepPath ( 'vue-hot-reload-api' )
1619
1720module . exports = function ( content ) {
1821 this . cacheable ( )
@@ -24,25 +27,18 @@ module.exports = function (content) {
2427 var moduleId = '_v-' + hash ( filePath )
2528 var styleRewriter = 'vue-loader/lib/style-rewriter?id=' + moduleId
2629
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- // respect user babel options
34- if ( this . options . babel ) {
35- defaultLoaders . js = 'babel-loader'
36- }
37-
38- // enable css source map if needed
39- if (
30+ var needCssSourceMap =
4031 this . sourceMap &&
4132 ! this . minimize &&
42- options . cssSourceMap !== false &&
43- process . env . NODE_ENV !== 'production'
44- ) {
45- defaultLoaders . css = 'vue-style-loader!css-loader?sourceMap'
33+ process . env . NODE_ENV !== 'production' &&
34+ options . cssSourceMap !== false
35+
36+ var defaultLoaders = {
37+ html : 'vue-loader/lib/template-compiler?id=' + moduleId ,
38+ css : styleLoaderPath + '!css-loader' + ( needCssSourceMap ? '?sourceMap' : '' ) ,
39+ js : this . options . babel
40+ ? 'babel-loader' // respect user options
41+ : 'babel-loader?presets[]=es2015&plugins[]=transform-runtime&comments=false'
4642 }
4743
4844 // check if there are custom loaders specified via
@@ -102,7 +98,7 @@ module.exports = function (content) {
10298 // unknown lang, infer the loader to be used
10399 switch ( type ) {
104100 case 'template' :
105- return defaultLoaders . html + '!' + templateLoader + '?raw&engine=' + lang + '!'
101+ return defaultLoaders . html + '!' + templateLoaderPath + '?raw&engine=' + lang + '!'
106102 case 'styles' :
107103 return defaultLoaders . css + '!' + rewriter + lang + '!'
108104 case 'script' :
@@ -198,7 +194,7 @@ module.exports = function (content) {
198194 ) {
199195 output +=
200196 '\nif (module.hot) {(function () {' +
201- ' var hotAPI = require("vue-hot-reload-api ")\n' +
197+ ' var hotAPI = require("' + hotReloadAPIPath + ' ")\n' +
202198 ' hotAPI.install(require("vue"), false)\n' +
203199 ' if (!hotAPI.compatible) return\n' +
204200 ' module.hot.accept()\n' +
0 commit comments