This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+13
View File
@@ -0,0 +1,13 @@
// utility for generating a uid for each component file
// used in scoped CSS rewriting
var path = require('path')
var hash = require('hash-sum')
var cache = Object.create(null)
var sepRE = new RegExp(path.sep.replace('\\', '\\\\'), 'g')
module.exports = function genId (file, context, key) {
var contextPath = context.split(path.sep)
var rootId = contextPath[contextPath.length - 1]
file = rootId + '/' + path.relative(context, file).replace(sepRE, '/') + (key || '')
return cache[file] || (cache[file] = hash(file))
}
+19
View File
@@ -0,0 +1,19 @@
var IS_TEST = !!process.env.VUE_LOADER_TEST
var fs = require('fs')
var path = require('path')
exports.lib = function (file) {
return path.resolve(__dirname, '../', file)
}
exports.dep = function (dep) {
if (IS_TEST) {
return dep
} else if (fs.existsSync(path.resolve(__dirname, '../../node_modules', dep))) {
// npm 2 or npm linked
return 'vue-loader/node_modules/' + dep
} else {
// npm 3
return dep
}
}