description and source-codevue-loader = function (content) {
this.cacheable()
var isServer = this.target === 'node'
var isProduction = this.minimize || process.env.NODE_ENV === 'production'
var loaderContext = this
var query = loaderUtils.getOptions(this) || {}
var options = this.options.__vueOptions__ = Object.assign({}, this.options.vue, this.vue, query)
var rawRequest = getRawRequest(this, options.excludedPreLoaders)
var filePath = this.resourcePath
var fileName = path.basename(filePath)
var context = (this._compiler && this._compiler.context) || this.options.context || process.cwd()
var moduleId = 'data-v-' + genId(filePath, context, options.hashKey)
var cssLoaderOptions = ''
if (!isProduction && this.sourceMap && options.cssSourceMap !== false) {
cssLoaderOptions += '?sourceMap'
}
if (isProduction) {
cssLoaderOptions += (cssLoaderOptions ? '&' : '?') + 'minimize'
}
var bubleOptions = hasBuble && options.buble
? '?' + JSON.stringify(options.buble)
: ''
var templateCompilerOptions = '?' + JSON.stringify({
id: moduleId,
transformToRequire: options.transformToRequire,
preserveWhitespace: options.preserveWhitespace,
buble: options.buble,
// only pass compilerModules if it's a path string
compilerModules: typeof options.compilerModules === 'string'
? options.compilerModules
: undefined
})
var defaultLoaders = {
html: templateCompilerPath + templateCompilerOptions,
css: options.extractCSS
? getCSSExtractLoader()
: styleLoaderPath + '!' + 'css-loader' + cssLoaderOptions,
js: hasBuble ? ('buble-loader' + bubleOptions) : hasBabel ? 'babel-loader' : ''
}
// check if there are custom loaders specified via
// webpack config, otherwise use defaults
var loaders = Object.assign({}, defaultLoaders, options.loaders)
var preLoaders = options.preLoaders || {}
var postLoaders = options.postLoaders || {}
function getRequire (type, part, index, scoped) {
return 'require(' +
getRequireString(type, part, index, scoped) +
')'
}
function getRequireString (type, part, index, scoped) {
return loaderUtils.stringifyRequest(loaderContext,
// disable all configuration loaders
'!!' +
// get loader string for pre-processors
getLoaderString(type, part, index, scoped) +
// select the corresponding part from the vue file
getSelectorString(type, index || 0) +
// the url to the actual vue file, including remaining requests
rawRequest
)
}
function getRequireForImport (type, impt, scoped) {
return 'require(' +
getRequireForImportString(type, impt, scoped) +
')'
}
function getRequireForImportString (type, impt, scoped) {
return loaderUtils.stringifyRequest(loaderContext,
'!!' +
getLoaderString(type, impt, -1, scoped) +
impt.src
)
}
function addCssModulesToLoader (loader, part, index) {
if (!part.module) return loader
var option = options.cssModules || {}
var DEFAULT_OPTIONS = {
modules: true,
importLoaders: true
}
var OPTIONS = {
localIdentName: '[hash:base64]'
}
return loader.replace(/((?:^|!)css(?:-loader)?)(\?[^!]*)?/, function (m, $1, $2) {
// $1: !css-loader
// $2: ?a=b
var query = loaderUtils.parseQuery($2 || '?')
Object.assign(query, OPTIONS, option, DEFAULT_OPTIONS)
if (index !== -1) {
// Note:
// Class name is generated according to its filename.
// Different <style> tags in the same .vue file may generate same names.
// Append `_[index]` to class name to avoid this.
query.localIdentName += '_' + index
}
return $1 + '?' + JSON.stringify(query)
})
}
function buildCustomBlockLoaderString (attrs) {
var noSrcAttrs = Object.assign({}, attrs)
delete noSrcAttrs.src
var qs = querystring.stringify(noSrcAttrs)
return qs ? '?' + qs : qs
}
// stringify an Array of loader objects
function stringifyLoaders (loaders) {
return loaders.map(function (obj) {
return obj & ...