Files
vue-cli/packages/@vue/cli-service/lib/util/getAssetPath.js
2018-06-11 15:33:34 -04:00

17 lines
492 B
JavaScript

const path = require('path')
module.exports = function getAssetPath (options, filePath, placeAtRootIfRelative) {
// if the user is using a relative URL, place js & css at dist root to ensure
// relative paths work properly
if (
placeAtRootIfRelative &&
!(/^https?:/.test(options.baseUrl)) &&
options.baseUrl.charAt(0) !== '/'
) {
return filePath.replace(/^\w+\//, '')
}
return options.assetsDir
? path.posix.join(options.assetsDir, filePath)
: filePath
}